Download MetaTrader 5

How can I change the color of every LevelValue/Lines in Indicator (SubWindow)?

To add comments, please log in or register
Musngi
307
Musngi  

How can I change the color of every LevellValue/Lines in Indicator (SubWindow)? 

Edit: I used SetLevelValue() to put indicator lines in my indicator (SubWindow).

Carl Schreiber
7291
Carl Schreiber  
In the terminal: F8 => Tab Colours => Foreground => choose your Colour - but it will be valid for the whole chart!
honest_knave
Moderator
2326
honest_knave  

If the objects are created manually, or by several indicators, or you don't have the source then loop through all the objects in the subwindow using ObjectsTotal(). The second parameter is for subwindow and the third parameter is for object type.

If the objects are only made by one indicator, and you have the source, then change the code in the indicator. 

ObjectsTotal - Object Functions - MQL4 Reference
ObjectsTotal - Object Functions - MQL4 Reference
  • docs.mql4.com
ObjectsTotal - Object Functions - MQL4 Reference
eevviill14
60
eevviill14  
Musngi:

How can I change the color of every LabelValue/Lines in Indicator (SubWindow)? 

ObjectSetInteger()

?
Musngi
307
Musngi  
honest_knave:

If the objects are created manually, or by several indicators, or you don't have the source then loop through all the objects in the subwindow using ObjectsTotal(). The second parameter is for subwindow and the third parameter is for object type.

If the objects are only made by one indicator, and you have the source, then change the code in the indicator. 

I used SetLevelValue() to put lines in my indicator in subwindow. There's no option to change color per different level.

Can you please give sample code?

Carl Schreiber
7291
Carl Schreiber  

Read (Editor F1 => search-tab) about IndicatorSetInteger(.., INDICATOR_LEVELCOLOR, ...

=> "Color of the level line,  color sets color for all levels"


Musngi
307
Musngi  
Carl Schreiber:

Read (Editor F1 => search-tab) about IndicatorSetInteger(.., INDICATOR_LEVELCOLOR, ...

=> "Color of the level line,  color sets color for all levels"


I tried that it don't work, it didn't change the color of indicators lines. Maybe something wrong in my code.

IndicatorSetDouble(INDICATOR_LEVELVALUE, 5, 0.01);
IndicatorSetInteger(INDICATOR_LEVELCOLOR, 5, clrRed);

Can you please give me sample code.

Mladen Rakic
61868
Mladen Rakic  
Musngi:

I tried that it don't work, it didn't change the color of indicators lines. Maybe something wrong in my code.

IndicatorSetDouble(INDICATOR_LEVELVALUE, 5, 0.01);
IndicatorSetInteger(INDICATOR_LEVELCOLOR, 5, clrRed);

Can you please give me sample code.

That will not work with mt4 - mt4 allows only one color for all levels (it will use the last color for levels that you try to set)

It works with mt5

In any case you shall have to have the following line too :

IndicatorSetInteger(INDICATOR_LEVELS, 6);      

If you want to see the 6th level too ("5" in those function calls means 6th level)

To add comments, please log in or register