How to use buffer colors for horizontal lines in MQL5

 

Good morning, fellow traders.


I am developing a indicator that changes my horizontal lines colors depending on the chart timeframe. I manage to code the whole logic of the indicator using hard coded colors, but, I now want to give the indicator some customizability.

I read a lot on how to use the indicator color properties, discovered that the color sheet is not meant to return a color, rather, be used in buffers and functions.

BUT, I saw some indicators that manage to extract what color parameter the user inputted (On the color sheet) and work with them.

I tried this approach on this topic (https://www.mql5.com/en/forum/226236), but its written in MQL4 and won't work on MQL5, and

SetIndexStyle

won't compile, saying its unindentified.


This is the code I used to change the colors

string result[];

for(int i = ObjectsTotal(ChartID(), -1, OBJ_HLINE) -1 ; i >= 0; i--) {
   string name = ObjectName(ChartID(),i);

   StringSplit(name, ' ', result);

   if(result[0] == "Daily") {
      ObjectSetInteger(ChartID(), name, OBJPROP_COLOR, clrMagenta);
}



How can I capture the color, width and style from and keep track of it as the user sets other values from (in MQL5)

#property indicator_color1
#property indicator_colorN & Text color is not a color; but a long?
#property indicator_colorN & Text color is not a color; but a long?
  • 2018.01.31
  • www.mql5.com
The idea was to see if one could use an indicator buffer color as a color for a text object...
Razão: