Today, I have rewrote my original ADX trading system. Entry signal stay same, but exit signals are now using DMI+ / DMI- crosses.
Source code: VTRS
{Control Error}
Err:= (Pr=0);
TH:=if(Ref(C,-1) > H,Ref(C,-1),H);
TL:=if(Ref(C,-1) <>
{ADX Indicator Calculation}
TR:=TH-TL;
PlusDM:=if(H>Ref(H,-1) AND L>=Ref(L,-1), H-Ref(H,-1),if(H >Ref(H,-1) AND L Ref(L,-1)-L, H-Ref(H,-1),0));
PlusDI:=100*Wilders(PlusDM,Pr)/Wilders(Tr,Pr);
MinusDM:=if(LRef(H,-1) AND L
MinusDI:=100*Wilders(MinusDM,Pr)/Wilders(Tr,Pr);
DIDif:=Abs(PlusDI-MinusDI);
DISum:=PlusDI+MinusDI;
ADXFinal:=100*Wilders(DIDif/DISum,Pr);
ADXRCustom:= (ADXFinal+Ref(ADXFinal,1-Pr))/2;
_ADX := if( cT=0,ADXFinal,ADXRCustom);
{Signal Long and Short}
Long:=not Err and Cross(PlusDI, MinusDI);
Short:=not Err and Cross(MinusDI, PlusDI);
UpTrend:=PlusDI>MinusDI;
DownTrend:=MinusDI>PlusDI;
{OpenBuy and CloseBuy}
OpenBuy:=not Err and Long and (eventCount('OpenBuy')= eventCount('CloseBuy'));
CloseBuy:=not Err and Short and (eventCount('OpenBuy')>eventCount('CloseBuy'));
{OpenSell and CloseSell}
OpenSell:=not Err and Short and (eventCount('OpenSell')= eventCount('CloseSell'));
CloseSell:=not Err and Long and (eventCount('OpenSell')>eventCount('CloseSell'));
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment