{Delta Stop for Trailing Stop Loss} DeltaStop:=if(Mode=0, Wilders(ATR (14),14) * 2.824, DeltaPrice); {Trailing Stop Loss Level} TrStopLevel:= If( C=PREV, PREV, If( ((Ref(C,-1)<=PREV)AND(C=PREV) AND (C>PREV), Max(PREV,(Close - DeltaStop)), If( C>PREV, (CLose - DeltaStop), (CLose + DeltaStop) ) ) ) ); {Signal Up and Down} Up:= Cross(Close,TrStopLevel); Down:= Cross(TrStopLevel,Close); {OpenBuy and CloseBuy} OpenBuy:= Up and (eventCount('OpenBuy')=eventCount('CloseBuy')); CloseBuy:= Down and (eventCount('OpenBuy')>eventCount('CloseBuy')); {OpenSell and CloseSell} OpenSell:= Down and (eventCount('OpenSell')=eventCount('CloseSell')); CloseSell:= Up and (eventCount('OpenSell')>eventCount('CloseSell'));