logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ROMEO TRADER  
#1 Posted : Friday, August 16, 2013 5:56:05 AM(UTC)
ROMEO TRADER

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2013(UTC)
Posts: 5

Hi All,

I'm looking for a N-day breakout expert that would give a buy signal when the close rises above the highest high value over the last N bars and would similarly give a sell signal when the close drops below the lowest low value over the last N bars.
this could be formulated as:
C > HHV(H, N) for a buy signal
and
C < LLV(L,N) for a sell signal
where N can be any normal, arbitrarily chosen, constant lookback period.

my problem is: what if I wanted the lookback period to change depending on changes in volatility?
for example by setting that N = 14* (Long term volatility / Short term volatility)

I thought I could do with:
N:=Int(14 * ( ATR(20) / ATR(10) ));
C > HHV(H,-N)

but I get an error message saying that "This variable or expression must contain only constant data".

I a true beginner, so I would appreciate any help with this.

thanks in advance for any response.
cheers.
Romeo Trader ;-)
mstt  
#2 Posted : Friday, August 16, 2013 3:20:06 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Romeo Trader

The solution to your problem is to use the Forum DLL. The syntax for the variable HHV function is ExtFml( "Forum.HHV", Data Array, Variable Period).

You can download this file form the Files section of this forum. The file you need to download is ForumDll_200. Since the name is quite a handful I have changed its name to Forum.DLL in all my MetaStock versions rather than use the more verbose ForumDll200 moniker. It's not as though a MetaStock formula has unlimited space, so why use a long name when a shorter one works just as well?

Copy the file into the "External Function Dlls" folder and then restart MetaStock.

Roy
ROMEO TRADER  
#3 Posted : Monday, August 19, 2013 5:42:18 AM(UTC)
ROMEO TRADER

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2013(UTC)
Posts: 5

Thank you very much indeed Roy. I downloaded the file and read the manual: this truly seems what I was looking.

I'll now try to work on that.

cheers,

Romeo
mstt  
#4 Posted : Monday, August 19, 2013 2:30:10 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Romeo

From memory I think that the Manual for the "Forum" DLL relates to ForumDll_112, an earlier version than the one I pointed you to. Be aware that syntax is different for some functions, and the selection of functions is also a little different.

Once the DLL is installed (and therefore recognised by MetaStock) there's an easy way to check what functions are available and what the syntax for each is. It's possible to have both the old and new Forum DLLs resident in MetaStock with different names.

Create a new indicator in the Indicator Builder,
click in the Formula window,
click the Functions... button,
mark Forum in the Function Category window,
and read off the functions in the Paste Functions window.

An even easier way to find functions provided by the 188KB Forum DLL is to check out the list below. Hope this helps.

Roy

ExtFml("Forum.CSAR",Low Array,High Array,Step);
ExtFml("Forum.DateRange",FirstDate,LastDate);
ExtFml("Forum.Latch",LE,LX,SE,SX);
ExtFml("Forum.Random",Min,Max);
ExtFml("Forum.TDCOMBO");
ExtFml("Forum.AroonDown",Data Array,Periods);
ExtFml("Forum.AroonUp",Data Array,Periods);
ExtFml("Forum.BBandBot",Data Array,Periods, deviations);
ExtFml("Forum.BBandTop",Data Array,Periods,deviations);
ExtFml("Forum.CCI",Periods) ;
ExtFml("Forum.CMO",Data Array,Variable Period);
ExtFml("Forum.Correl",INDEPENDENT Array,DEPENDENT Array, Periods) ;
ExtFml("Forum.HHV",Data Array,Variable Period);
ExtFml("Forum.HHVBARS",Data Array,Variable Period);
ExtFml("Forum.LLV",Data Array,Variable Period);
ExtFml("Forum.LLVBARS",Data Array,Variable Period);
ExtFml("Forum.MACD",Data Array,Slow Periods,Fast Periods);
ExtFml("Forum.MOM",Data Array,Variable Period);
ExtFml("Forum.MOV",Data Array,Variable Period,Method);
ExtFml("Forum.PriceChannelHigh",Data Array, Periods);
ExtFml("Forum.PriceChannelLow",Data Array,Periods);
ExtFml("Forum.RSquared",Data Array,Periods);
ExtFml("Forum.ROC",Data Array,Periods,(0 | 1));
ExtFml("Forum.Ref",Data Array,Variable Period);
ExtFml("Forum.RSI",Data Array,Variable Period);
ExtFml("Forum.Stdev",Data Array,Periods,Deviation);
ExtFml("Forum.Stoch",Periods);
ExtFml("Forum.Sum",Data Array, Variable Period);
ExtFml("Forum.TSF",Data Array,Periods);
ExtFml("Forum.TRIX",Data Array,Periods);

ROMEO TRADER  
#5 Posted : Tuesday, August 20, 2013 6:41:32 AM(UTC)
ROMEO TRADER

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2013(UTC)
Posts: 5

Hi Roy,

thank you very much indeed for helping. the dll functions were easy to find.

however, I have been trying to use the HHV and LLV in my expert symbol as follows:
for a buy signal:
hhv1:= ExtFml("Forum.HHV",H ,(20 * (ATR(50) / ATR(10))));
Cross(C,hhv1)

for a sell signal:
llv1:= ExtFml("Forum.LLV",L ,(20 * (ATR(50) / ATR(10))));
Cross(llv1,c)

but after attaching this expert to my chart, no signal would show up...

Am I making anything wrong?
haddison  
#6 Posted : Tuesday, August 20, 2013 2:08:05 PM(UTC)
haddison

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/6/2010(UTC)
Posts: 113
Location: London

I think you need to backward ref your formulae, because the LLV and HHV include the current bar.
mstt  
#7 Posted : Tuesday, August 20, 2013 2:23:37 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Romeo

The problem arises because of your use of the the Cross() function where the CLOSE can never be higher than HHV(H,periods) or lower than LLV(L,periods). As written it doesn't matter what the lookback period is because the CLOSE will never cross outside of the HHV(H) and LLV(L) extremes. You need to rethink what you're trying to do.

Can I suggest that in future you move any problem Expert or Exploration code across to the Indicator Builder and then check the outputs of each line of code (or inner workings if necessary) until you spot the problem. That can be a laborious process, but it works. MetaStock will give up its secrets with a little coaxing.

Roy


ROMEO TRADER  
#8 Posted : Wednesday, August 21, 2013 3:12:02 AM(UTC)
ROMEO TRADER

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 8/16/2013(UTC)
Posts: 5

problem solved! thank you very much!
not only are these my initial approaches to Metastock, but even to programming in general! so I still need to fully catch the logic behind functions, formulas, etc... but all this stuff looks extremely interesting I must say and this excellent forum just gives me more motivation :-)

Thank you for your suggestion Roy, which I will follow for sure! ;-)

cheers.

Romeo.
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.