Rank: Newbie
Groups: Registered, Registered Users, Subscribers Joined: 9/13/2010(UTC) Posts: 7
|
Hello all,
I'm trying to create a System Tester that uses the Vervoort ATR Trailing stop. I look for confirmation of the weekly and the daily charts. The code for the trailing stop indicator I use on either daily or weekly charts is:
{SVE_Stop_Trail_ATR_Mod} period:=Input("ATR period:",1,100,5); atrfact:=Input("ATR multiplication:",1,10,3.5); HiLo:=If(H-L<1.5*Mov(H-L,period,S),H-L, 1.5*Mov(H-L,period,S)); Href:=If(L<=Ref(H,-1),H-Ref(C,-1),(H-Ref(C,-1))-(L-Ref(H,-1))/2); Lref:=If(H>=Ref(L,-1),Ref(C,-1)-L,(Ref(C,-1)-L)-(Ref(L,-1)-H/2)); diff1:=Max(HiLo,Href); Diff2:=Max(diff1,Lref); atrmod:=Wilders(diff2,period); loss:=atrfact*atrmod; trail:= If(C>PREV AND Ref(C,-1)>PREV, Max(PREV,C-loss), If(C<PREV AND Ref(C,-1)<PREV, Min(PREV,C+loss), If(C>PREV,C-loss,C+loss))); Trail
Obviously this will give a different result based on the periodicity of the chart it is plotted on. Since I'm using daily data for the System Tester I want to be able to re-create the trailing stop this formula calculates on the weekly chart on the daily, (this is a key buy confirmation and sell trigger for me). I thought that if I used the HHV(H,5) and LLV(L,5) in place of the H and L in the formula I might get close. This is the code I derived:
{SVE_Stop_Trail_ATR_Mod} period:=Input("ATR period:",1,100,5); atrfact:=Input("ATR multiplication:",1,20,3.5); HiLo:=If((HHV(H,5)-(LLV(L,5))<1.5*Mov((HHV(H,5)-(LLV(L,5))),period,S)),((HHV(H,5)-(LLV(L,5)))),1.5*Mov((((HHV(H,5)-(LLV(L,5))))),period,S)); Href:=If(((LLV(L,5)<=Ref((HHV(H,5)),-1))),((HHV(H,5))-Ref(C,-1)),((HHV(H,5))-Ref(C,-1)))-(((LLV(L,5)-Ref(HHV(H,5),-1)/2))); Lref:=If(((HHV(H,5))>=Ref((LLV(L,5)),-1)),Ref(C,-1)-((LLV(L,5))),(Ref(C,-1)-((LLV(L,5)))-((Ref((LLV(L,5)),-1)-(HHV(H,5)))/2))); Diff1:=Max(HiLo,Href); Diff2:=Max(diff1,Lref); atrmod:=Wilders(diff2,period); loss:=atrfact*atrmod; trail:= If(C>PREV AND Ref(C,-1)>PREV, Max(PREV,C-loss), If(C<PREV AND Ref(C,-1)<PREV, Min(PREV,C+loss), If(C>PREV,C-loss,C+loss))); Trail
When I plot this on a daily chart and compare it to the weekly it still doesn't align. Clearly I'm no wizard--any suggestions?
thanks
Glen
|