Hi Members,
I found the below code on wisestocktrader.com for plotting MACD colored Histogram.
Please help me to edit the below code so that there are only two colors in Histogram. Above 0 Green and below 0 Red.
***********************************
_SECTION_BEGIN("MACD coloured");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
mm = MACD(r1, r2);
ms = Signal(r1, r2, r3);
mh = mm-ms;
mc = IIf(mh>Ref(mh,-1),IIf(mh > 0,27,41),IIf(mh > 0,43,32));
Plot(mm,StrFormat(_SECTION_NAME()+"(%g,%g)", r1 ,r2),12,4);
Plot(ms," Signal" + _PARAM_VALUES(),11);
Plot(mh,"MACDHistogram",mc,6|styleNoTitle|32768|4096);
Plot(mh,"MACDHistogram",mc,5|styleNoTitle|32768|4096);
Plot(0,"zero",colorBlack,styleLine);
Plot(mm,StrFormat(_SECTION_NAME()+"(%g,%g)", r1 ,r2),12,4);
Plot(ms," Signal" + _PARAM_VALUES(),11);
Plot(mh,"MACDHistogram",mc,6|styleNoTitle|32768|4096);
Plot(mh,"MACDHistogram",mc,5|styleNoTitle|32768|4096);
Buy= Cross(mm,ms );
Sell=Cross(ms,mm );
shape = Buy * shapeUpArrow+ Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ), 0, IIf( Buy, ms,ms ) );
_SECTION_END();
**************************************
Thanks All.
I found the below code on wisestocktrader.com for plotting MACD colored Histogram.
Please help me to edit the below code so that there are only two colors in Histogram. Above 0 Green and below 0 Red.
***********************************
_SECTION_BEGIN("MACD coloured");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
mm = MACD(r1, r2);
ms = Signal(r1, r2, r3);
mh = mm-ms;
mc = IIf(mh>Ref(mh,-1),IIf(mh > 0,27,41),IIf(mh > 0,43,32));
Plot(mm,StrFormat(_SECTION_NAME()+"(%g,%g)", r1 ,r2),12,4);
Plot(ms," Signal" + _PARAM_VALUES(),11);
Plot(mh,"MACDHistogram",mc,6|styleNoTitle|32768|4096);
Plot(mh,"MACDHistogram",mc,5|styleNoTitle|32768|4096);
Plot(0,"zero",colorBlack,styleLine);
Plot(mm,StrFormat(_SECTION_NAME()+"(%g,%g)", r1 ,r2),12,4);
Plot(ms," Signal" + _PARAM_VALUES(),11);
Plot(mh,"MACDHistogram",mc,6|styleNoTitle|32768|4096);
Plot(mh,"MACDHistogram",mc,5|styleNoTitle|32768|4096);
Buy= Cross(mm,ms );
Sell=Cross(ms,mm );
shape = Buy * shapeUpArrow+ Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorBlue, colorRed ), 0, IIf( Buy, ms,ms ) );
_SECTION_END();
**************************************
Thanks All.
Last edited: