Adding Color to MCAD Histograms

 

Greetings All,

I'm not an mq4 or c expert, but this seems like it would be fairly easy for someone who is. I'm looking for a way to add some additional coloring to a standard MCAD indicator - specifically the histogram portion - in order to make it easier to read at a quick glance (when multiple charts are on the screen).

Essentially, I'd like to see positive histogram values in green and negative ones in red, with two shades of each color. If the plotted line is longer than the previous, the color is the brighter of the two, shorter than the previous then darker. (So, histogram is showing negative values in red, lower one is bright red, higher one is dark red; positive values shown in green, a higher bar is bright green, a lower bar is dark green.)

The long and short MCAD lines can be any color besides the 4 shades used for the histogram. Can anyone help by supplying some sample code? I've spent some time looking at the mq4 code of a regular MCAD indicator, and some of it makes sense, but am not sure how to go about adding additional color choices or rules for their plotting on the chart.

Thanks in advance!

 

2 Colour Histo

andrei23:
Greetings All,

I'm not an mq4 or c expert, but this seems like it would be fairly easy for someone who is. I'm looking for a way to add some additional coloring to a standard MCAD indicator - specifically the histogram portion - in order to make it easier to read at a quick glance (when multiple charts are on the screen).

Essentially, I'd like to see positive histogram values in green and negative ones in red, with two shades of each color. If the plotted line is longer than the previous, the color is the brighter of the two, shorter than the previous then darker. (So, histogram is showing negative values in red, lower one is bright red, higher one is dark red; positive values shown in green, a higher bar is bright green, a lower bar is dark green.)

The long and short MCAD lines can be any color besides the 4 shades used for the histogram. Can anyone help by supplying some sample code? I've spent some time looking at the mq4 code of a regular MCAD indicator, and some of it makes sense, but am not sure how to go about adding additional color choices or rules for their plotting on the chart.

Thanks in advance!

This should help, it is a MACD that has a 2 colour Histo and an indicator called OsMA multi coloured Histo which is coded very similar to the MACD Histo, you should be able to get enough code out of these 2 to do the trick. Thinking on this you may run out of Buffers as only 8 are allowed? good luck

cja

macd_2_colour_histogram.mq4

osma_color_1s.mq4

 

Thanks!

This is perfect, thanks so much! I learn best by pasting together parts from other code. The logic for choosing colors based on bar height is what I lacked, and this is perfect. Thanks for the heads-up on buffer limits as well.

Best,

-=Andrei

Reason: