Download MetaTrader 5

Custom indicator color - page 2

To add comments, please log in or register
Simon Gniadkowski
Moderator
18002
Simon Gniadkowski 2014.08.21 19:33  
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 ?
Halley
198
Halley 2014.08.21 20:13  
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.

emmzett
17
emmzett 2014.08.21 21:11  

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

emmzett
17
emmzett 2014.08.21 21:23  

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

emmzett
17
emmzett 2014.08.21 21:40  

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

emmzett
17
emmzett 2014.08.21 21:43  
12
To add comments, please log in or register