[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: n-day breakout system



PureBytes Links

Trading Reference Links

In functions like HHV, etc. Metastock language requires a constant for the 
length of the function.  You need to look at the LASTVALUE() function for 
using as a constant in the HHV function.  Try the following code.  

n:=20*(Stdev(C,20)/Mov(Stdev(C,20),5,S));
nhigh:=Ref(HHV(H,LastValue(n)),-1);
HIGH>nhigh AND CLOSE > Ref(CLOSE,-1)

Hope this works for you.  There are some quirks with using LASTVALUE, but I 
can't remember what they are.  Maybe some one else on the list can help 
identify the quirks.

Kevin Campbell


In a message dated 2/26/00 6:47:50 AM Central Standard Time, 
jcob3@xxxxxxxxxxx writes:

> Help needed for formula wizards.
>  
>  I have coded the entry for the n-day breakout system from Perry Kaufmann's 
"
> Trading Systems and Methods" as: 
>  ENTER LONG:
>  
>  n:=20;
>  nhigh:=Ref(HHV(H,n),-1);
>  HIGH>nhigh AND CLOSE > Ref(CLOSE,-1)
>  
>  I would like to be able to vary "n" using a volatility multiplier like 
this 
> one taken from Chande's "The New Technical Trader",
>  
>  Stdev(C,20)/Mov(Stdev(C,20),5,S), so that, ultimately "n" will equal 20*(
> Stdev(C,20)/Mov(Stdev(C,20),5,S)).  
>  
>  So far so good, but when I try to implement this into the ENTER LONG 
Formula 
> I get the following error message.
>  
>  "This variable or expression must contain only constant data.", referring 
to 
> the "n" in the "nhigh" formula.
>  
>  n:=20*(Stdev(C,20)/Mov(Stdev(C,20),5,S));
>  nhigh:=Ref(HHV(H,n),-1);
>  HIGH>nhigh AND CLOSE > Ref(CLOSE,-1)
>  
>  After pondering this I thought that maybe it was because the "n" needed to 
> be a whole number for this particular formula; after all, it must be 
> difficult to select a highest high value for a fractional day.  Therefore, 
I 
> altered the formula thusly: 
>  n:=int(20*(Stdev(C,20)/Mov(Stdev(C,20),5,S))).  I was willing to accept 
that 
> the program would round every decimal down.  Unfortunately, I received the 
> same error.  This makes little sense to me since I can simply put n:= opt1 
> for as many days as I want and the formula works just fine.
>  
>  Any help with this little conundrum will be greatly appreciated.
>  
>  Jeff
>