internette her yerde bulunabilen soploss
{ User Inputs }
multi:=Input("ATR multiplier",0,10,2.5);
pds:=Input("ATR periods",1,252,10);
pds1:=Input("ATR lookback periods",1,252,21);
plot:=Input("[1]Trailing Stop, [2]Long+Short, [3]Signals",1,3,1);
adv:=Input("plot: today's trailing stop=0, tomorrow's stop=1",0,1,0);
delay:=Input("Entry and Exit signal delay",0,5,0);

{ Trailing Stops }
StLong:=HHV(C-multi*Mov(ATR(1),pds,E),pds1);
StShort:=LLV(C+multi*Mov(ATR(1),pds,E),pds1);
stopLong:=If(C<PREV,StLong,Max(StLong,PREV));
stopShort:=If(C>PREV,StShort,Min(StShort,PREV));

{ Trade flags/signals }
In:=Cross(C,Ref(stopShort,-1));
Out:=Cross(Ref(stopLong,-1),C);
Init:=Cum(IsDefined(In+Out))=1;
x:=ValueWhen(1,In-Out<>0 OR Init,In-Out);
long:=x=1 AND (Alert(x<>1,2) OR Init);
short:=x=-1 AND (Alert(x<>-1,2) OR Init);
signals:=long-short;
flag:=ValueWhen(1,signals<>0 OR Init,signals);

{ Switch between Long/Short stops }
stop:=Ref(If(flag=1,stopLong,stopShort),-1+adv);

{ Plot in price chart }
If(plot=1,stop,
If(plot=2,Ref(stopLong,-1+adv),0));
If(plot=1,stop,
If(plot=2,Ref(stopShort,-1+adv),signals));
C;