Here's an example of the code I used to modify the colors in the shi_channel indicator. The channel color was green all the time. I modified it so that depending on if it was an up or down sloping channel, the color would either be green or red.
Take a look at the IF statement to see how I did it....
// Channel is Green if width is greater than ChannelAlert (Default 50),
// otherwise it is Red
if(ChannelWidth >= ChannelAlert) {ObjectSet("TL1",OBJPROP_COLOR,Lime);}
else {ObjectSet("TL1",OBJPROP_COLOR,Red); }
ObjectSet("TL1",OBJPROP_WIDTH,2);
ObjectSet("TL1",OBJPROP_STYLE,STYLE_SOLID);All you need to do is create an IF statement, and based on the outcome of the IF statement, the OBJPROP_COLOR will be set to this or that color.
Hope that helps.
Keris
I am struggling with getting my coding to work.
If I am using an oscillator with 2 lines that moves around the zero line, how do I programme in MetaTrader4 for the line to change colour when line A is above line B and > zero line and similarly display a different colour when it is < zero ?
thanksbillm,
Could we see the code?
thanks, I'll try that method
Do you know of a way of displaying 2 or more seperate indicators in the same window? eg; a line based indicator and a histogram, both using different code rather than trying to merge the 2 codes together ?
I'm just trying to make best use of screen space thats all
thanks

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am struggling with getting my coding to work.
If I am using an oscillator with 2 lines that moves around the zero line, how do I programme in MetaTrader4 for the line to change colour when line A is above line B and > zero line and similarly display a different colour when it is < zero ?
thanks