The idea was to see if one could use an indicator buffer color as a color for a text object,.
Initially, it works! And as for example you have a moving average line and a text object using indicator_color1 they would both be the same color with Green/clrGreen/0x008000.
But, when you changed the color from the input parameters you would notice that only the moving average line had changed; and the text object color remained the previous color that the indicator buffer color had. Broken compatibility?
Which led me to believe that once the indicator had loaded initially the values had changed from long/integer into color like clrGreen, like from machine code initially?, which when later set as text color doesn't work because it requires it to be a long value -however- if you simply set the text color with Green/clrGreen it works and it didn't need to be a long. Thus, no matter what the indicator buffer color was initially once it was changed it broke compatibility.
And of course, it used to be that you didn't have to worry about using any conversion formulas and there are no conversion formulas present in the documentation to turn a color into long like clrGreen to 0x008000.. They are built-in for setting text color, but not with #property indicator_colorN.
Therefore, one would need to create more inputs and change them both to effectively have the same color for two objects?
Why can't you use the #property indicator_colorN for text objects other than initially? Well, knowing me, it's probably a bug.
When you changed the color from the input parameters you don't change "indicator_color1" value. If you want to change indicator color together with text object color you should insert it into inputs:
input color colorIndicator; // Indicator color
and then you can use this both in indicator settings:
SetIndexStyle(0,DRAW_LINE,EMPTY,EMPTY,colorIndicator);
and text object settings:
ObjectSetInteger(0,name,OBJPROP_COLOR,colorIndicator);
Something like this doesn't work?
#property indicator_color1 = clrGreen
ObjectSetInteger(0,name,OBJPROP_COLOR,indicator_color1);
It will when you compile it, and indicator is on the chart,
if you change the color - it doesn't change.
Something like this doesn't work?
It will when you compile it, and indicator is on the chart,
if you change the color - it doesn't change.
#property indicator_color1 is preprocessor. It prepares properties before the program is compiled and during the program running it will never change even when you change the color of the indicator.
P.S.
You can't use "="
#property indicator_color1 clrGreen
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
The idea was to see if one could use an indicator buffer color as a color for a text object,.
Why can't you use the #property indicator_colorN for text objects other than initially?
Initially, it works! And, as for example you have a moving average line and a text object using indicator_color1 and they would both be the same color with Green/clrGreen/0x008000.
But when you changed the color from the input parameters you would notice that only the moving average line had changed; and the text object color remained the previous color that the indicator buffer color had(Broken compatibility?) which led me to believe that once the indicator had loaded initially the values had changed from long/integer into color like clrGreen, like from machine code ?, which when later set as text color doesn't work because it requires it to be a long value -however- if you simply set the text color with Green/clrGreen it works and it didn't need to be a long.
Thus, no matter what the indicator buffer color was initially once it was changed it broke compatibility.
And, of course, it used to be that you didn't have to worry about using any conversion formulas and there are no conversion formulas present in the documentation to turn a color into long like clrGreen to 0x008000.. They are built-in for setting text color, but apparently not with #property indicator_colorN.
Therefore, one would need to create another color input and change both colors to effectively have the same color for two objects?