i think its right
//MACD
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
m1 = MACD(r1, r2);
s1 = Signal(r1,r2, r3);
//stochastic
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
periods = Param( "Periods", 15, 1, 200, 1 );
k=StochK( periods , Ksmooth);
d=StochD( periods , Ksmooth, DSmooth );
//ADX
range = Param("Periods", 14, 2, 200, 1 );
ADvX=ADX( range);
tightstop=1;
Loosestop=2;
ApplyStop(stopTypeL oss,stopModePerc ent,IIf(advx>45,tightstop, Loosestop) );
Buy=IIf(advx<20,k>d,IIf(advx>30,m1>s1,IIf(Cross( Advx,23) AND LLV(advx,BarsSince( Cross(23, advx)))<18,m1>s1,
IIf(Cross(27, advx) AND HHV(advx,BarsSince( Cross(advx, 27))),k>d,0))));
Sell=IIf(advx<20,k<d,IIf(advx>30,m1<s1,IIf(Cross( Advx,23) AND LLV(advx,BarsSince( Cross(23, advx)))<18,m1<s1,
IIf(Cross(27, advx) AND HHV(advx,BarsSince( Cross(advx, 27))),k<d,0))));
Short=Cover= 0;
Buy=ExRem(Buy,
Sell);
Sell=ExRem(Sell, Buy);