ATR Trailing Stop Expert Indicator Per1:=30; RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1)); RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1)); Pk:=Mov((RWH-RWL),3,W); Val1.5:=If(Pk>0,HHV(H-1.5*ATR(5),10),LLV(L+1.5*ATR(5),10)); Val1.5; Highlights Tab Long Per1:=30; RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1)); RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1)); Pk:=Mov((RWH-RWL),3,W); Val1.5:=If(Pk>0,HHV(H-1.5*ATR(5),10),LLV(L+1.5*ATR(5),10)); Buy:=C>Val1.5; Sell:=C-1 AND sell>-1)=1; x:=BarsSince(i OR buy)<=BarsSince(i OR sell)=0; X=0 Short Per1:=30; RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1)); RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1)); Pk:=Mov((RWH-RWL),3,W); Val1.5:=If(Pk>0,HHV(H-1.5*ATR(5),10),LLV(L+1.5*ATR(5),10)); Buy:=C>Val1.5; Sell:=C-1 AND sell>-1)=1; x:=BarsSince(i OR buy)>=BarsSince(i OR sell)=0; X=0 Symbol Tab Long Per1:=30; RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1)); RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1)); Pk:=Mov((RWH-RWL),3,W); Val1.5:=If(Pk>0,HHV(H-1.5*ATR(5),10),LLV(L+1.5*ATR(5),10)); Buy:=C>Val1.5; Sell:=C-1 AND sell>-1)=1; x:=BarsSince(i OR buy)<=BarsSince(i OR sell)=0; X=0 AND Ref(X,-1)>0 Short Per1:=30; RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1)); RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1)); Pk:=Mov((RWH-RWL),3,W); Val1.5:=If(Pk>0,HHV(H-1.5*ATR(5),10),LLV(L+1.5*ATR(5),10)); Buy:=C>Val1.5; Sell:=C-1 AND sell>-1)=1; x:=BarsSince(i OR buy)>=BarsSince(i OR sell)=0; X=0 AND Ref(X,-1)>0 *****ATR Trailing stop***** Per1:=30; RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1)); RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1)); Pk:=Mov((RWH-RWL),3,W); {OSC} Val1.5:=If(Pk>0,HHV(H-1.5*ATR(5),10),LLV(L+1.5*ATR(5),10)); {ATR Stop} Buy:=C>Val1.5; {Buy Condition} Sell:=C-1 AND sell>-1)=1; x:=BarsSince(i OR buy)>=BarsSince(i OR sell)=0; X=0 AND Ref(X,-1)>0 we created an oscillator based on the high vs low of 30 days ago,the low vs the high of 30 days ago devided by the atr of 30 days time the square root of 30. If this osc is above 0 we use the highest value of the past ten periods of the high minus 1.5 times the ATR of 5 periods as a trailing stop for long positions. If this osc is Below 0 we use the lowest value of the past ten periods of the low plus 1.5 times the ATR of 5 periods as a trailing stop for short positions.