AAAAStop_Trail_ATR_ModAAAAStop_Trail_ATR_ModAAAAPeriod$FAAAAAAatrfactAAAA3.AAAAHAAZAAAALAAAAAAHAAAAAALAAAAAAMOVAAAAPricetvAAAAAALengthpeAAAAAAMethodpeAAAA5AAAAHAAaAAAALAAAAAAHAAAAAALAAAAAAMOVAAAAPricetvAAAAAALengthpeAAAAAAMethodpeAAAA*AAAAIFFAAAA Condition= 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:=EMA(diff2,period); loss:=atrfact*atrmod; if HISTORYSIZE <= period then result := C; else begin if C > this\1\ AND C\1\ > this\1\ then result := Max(this\1\,C-loss); else begin if C < this\1\ then result := Min(this\1\,C+loss); else begin if C > this\1\ then result := C-loss; else result := C+loss; end; end; end; return result;AA