Changing chart color
No, and ..... yes!
Use *TWO* indicators. Or 4, like this. It uses 2 colours, and also 2 bar widths to show whether signal line is within the bars range ...
#property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 Maroon #property indicator_width1 3 #property indicator_width2 1 #property indicator_width3 3 ... double MacdBufferRising[]; double MacdBufferFalling[]; double MacdBufferRisingThin[]; double MacdBufferFallingThin[]; double MacdBufferRaw[]; double SignalBuffer[]; ... IndicatorBuffers(8); SetIndexStyle(0,DRAW_HISTOGRAM, indicator_style1, indicator_width1, indicator_color1); SetIndexStyle(1,DRAW_LINE, indicator_style2, indicator_width2, indicator_color2); SetIndexStyle(2,DRAW_HISTOGRAM, indicator_style3, indicator_width3, indicator_color3); SetIndexStyle(3,DRAW_HISTOGRAM, indicator_style1, indicator_width1-1, indicator_color1); SetIndexStyle(4,DRAW_HISTOGRAM, indicator_style3, indicator_width3-1, indicator_color3); SetIndexStyle(7,DRAW_NONE); ... SetIndexBuffer(0,MacdBufferRising); SetIndexBuffer(1,SignalBuffer); SetIndexBuffer(2,MacdBufferFalling); SetIndexBuffer(3,MacdBufferRisingThin); SetIndexBuffer(4,MacdBufferFallingThin); SetIndexBuffer(5,MacdBufferRaw); ... for(int ix=ixLimit; ix>=0; ix--) { MacdBufferRising[ix]=EMPTY_VALUE; MacdBufferRisingThin[ix]=EMPTY_VALUE; MacdBufferFalling[ix]=EMPTY_VALUE; MacdBufferFallingThin[ix]=EMPTY_VALUE; SignalBuffer[ix]=EMPTY_VALUE; rawM=iMA(NULL,0,FastPeriods,0,FastMAMode_0SmaEmaSmmaLwma3,FastPrice_0COHLMedTypWgt6,ix)- iMA(NULL,0,SlowPeriods,0,SlowMAMode_0SmaEmaSmmaLwma3,SlowPrice_0COHLMedTypWgt6,ix); MacdBufferRaw[ix]=rawM; rawS=iMAOnArray(MacdBufferRaw,0,SignalPeriods,0,SignalMAMode_0SmaEmaSmmaLwma3,ix); if(rawS != EMPTY_VALUE) SignalBuffer[ix]=ValueCompress(rawS, PeakCompressionRatio); bool isThin = false; if(rawS * rawM > 0) // if both same side of zero .. if(MathAbs(rawS) > MathAbs(rawM)) // signal clear of MACD bars isThin = true; if(rawM > MacdBufferRaw[ix+1]) if(isThin) MacdBufferRisingThin[ix]=ValueCompress(rawM, PeakCompressionRatio); else MacdBufferRising[ix]=ValueCompress(rawM, PeakCompressionRatio); else if(isThin) MacdBufferFallingThin[ix]=ValueCompress(rawM, PeakCompressionRatio); else MacdBufferFalling[ix]=ValueCompress(rawM, PeakCompressionRatio); }
Oops - ignore ValueCompress - it makes small histogram bars easier to see by compressing the long ones.
Hi,
Is it possible to change chart color in MetaTrader 4 ?
For example,
is Macd > 0, color Green
is Macd < 0, color Red
Thanks !