// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Buysell");
//a = Param("sma",15,5,25,1);
//b = Param("lma",25,20,50,1);
a = Optimize("a",15,5,25,1);
b = Optimize("b",25,20,50,1);
//d = Optimize("d",50,40,60,1);
//a = 18;
//b = 22;
a1 = Cross(MA(C,a),MA(C,b));//)AND C>MA(C,d);

a2 = Cross(MA(C,b),MA( C,a));
Plot(C,"price",colorBlack,styleBar);
Plot(MA(C,a),"sma",colorRed,styleLine);
Plot(MA(C,b),"lma",colorGreen,styleLine);

uptrend = PDI()>MDI();
downtrend = MDI()>PDI();
a=Param("ribonhight",5,1,20,1);
Plot(a, "market trend",IIf(uptrend,colorGreen,IIf(downtrend,colorRed,7)), styleOwnScale|styleArea|styleNoLabel, -0.5,100);
Buy = a1 AND uptrend ;
Sell = a2 AND downtrend;
Short = Sell ;
Cover = Buy ;
PlotShapes(Buy*shapeUpArrow + Sell*shapeDownArrow, IIf(Buy,colorGreen,colorRed));
_SECTION_END();