Hist Band MACD Perfect Trading

Hist Band MACD Perfect Trading
Hist Band MACD Perfect Trading

//www.aflcode.com
_SECTION_BEGIN("MACD");
r1 = Optimize( "Fast avg", 3, 3, 20, 1 );
r2 = Optimize( "Slow avg", 11, 5, 30, 1 );
r3 = Optimize( "Signal avg", 16, 3, 20, 1 ); 
ml = MACD(r1, r2);
sl = Signal(r1,r2,r3);
Hst = ml-sl;
Color = IIf (Hst > Ref(Hst,-1),colorBlue,colorRed);

//Plot( ml = MACD(3, 11), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
//Plot( sl = Signal(3,11,16), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
Plot( Hst, "MACD Histogram",  color , styleThick  );
bbtop = BBandTop( Hst, 9, 1 );
bbbot = BBandBot( Hst, 9,1 );
Plot( BBandTop( Hst, 9, 1 ), "BBTop", colorYellow, styleDashed ); 
Plot( BBandBot( Hst, 9,1 ), "BBBot", colorYellow, styleDashed ); 

Buy = Cross (Hst,bbtop);
Sell = Cross (bbtop,Hst);
Short = Cross (bbbot,Hst);
Cover = Cross (Hst,bbbot);

//Sell = Short;
//Cover = Buy ;

PlotShapes (Buy*shapeUpArrow,colorYellow);
PlotShapes (Short*shapeDownArrow,colorYellow);
//PlotShapes (Sell*shapeHollowSmallDownTriangle,colorRed);
//PlotShapes (Cover*shapeHollowSmallUpTriangle,colorGreen);

Plot(6, "ribbon", Color, styleOwnScale| styleArea|styleNoLabel,-0.5,100);
_SECTION_END();
Previous
Next Post »