Custom indicator color - page 2

 
DeepThought:

In case the indicator code is available, you may add broadcasting a custom event to all charts after you detected colour change.
How would you detect the colour change ?
 
RaptorUK:
How would you detect the colour change ?


Apologies.

For some reason I expected that IndicatorSetInteger has its Get counterpart. It does not. Thank you for keeping an eye on my blind guess.

 

Yes, it has always been possible in MQL4 to control colors from code but you need to use a little "trick". You have to specify the color as an input parameter, not as regular colors. You can't read (get) regular colors from code but you can write (set) them.

So the solution is to completely make the color management from code and just forget about the "Colors" tab, in this special case.

Programmable colors

 

The above picture shows object colors managed by code but the same works for indicator colors as well, as illustrated here:

Color management for indicators

 

Here is another example. The indicator inputs take only one color for a main Bollinger band line. The indicator is able to draw a histogram made by two Bollinger bands, for example the histogram between the EMA and the SMA Bollinger band. If a histogram is requested the indicator simply takes the specified main color, increases the lightness of it and applies it on the fly to the histogram. So, if I change the main line color to red the histogram becomes light-red.


On the fly manipulation of indicator colors

 
Reason: