// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Rockwell Bar Colour");
// By StockManiacs.net
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
ml = MACD(12, 26);
sl = Signal(12,26,9);


state = IIf((ml<0 AND sl>ml),-1,IIf((ml>0 AND sl<ml),1,0));
Color = IIf(state == 0, colorBlack, IIf(state == 1, colorLime, IIf(state == -1, colorRed, 0)));

//Plot(state, "", color, styleHistogram);

SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", color, styleNoTitle |styleBar );


P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style ); 
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style ); 
_SECTION_END();

// Plots a 50 period Donchian channel

pds=50;
DonchianUpper =HHV(Ref(H,-1),pds);
DonchianLower = LLV(Ref(L,-1),pds);
DonchianMiddle = (DonchianUpper+DonchianLower)/2;


Plot(DonchianUpper,"DU",colorBlue,styleLine);
Plot(DonchianMiddle,"DM",colorYellow,styleLine);
Plot(DonchianLower,"DL",colorRed,styleLine); 
_SECTION_END();