Download MetaTrader 5

Is it possbile to set a different color for all (trend)lines in the chart at once (maybe a script)?

To add comments, please log in or register
mar
1147
mar  

Hi Forum,

I use many horizontal / trendlines in my chart and sometimes I like to change the colors of them. It is really much work when you have to do it with 15 charts.

Therefore I wanted to know if it is possible to set a new color for all lines in the chart with a script. Maybe somebody already has something like this? My searching was not successful...

Ubzen
5394
Ubzen  

If you're a programmer or learning to program then use the available mql4 function to accomplish the task. Otherwise you can make a request here and someone will help you with that.

Here are the list of object functions. https://docs.mql4.com/objects/ObjectCreate. On the left column. Generally you search for the object just like searching for orders. You ObjectGet() the Property_Color && Property_TrendLine for Checking. Then you ObjectSet() to what you want.

mar
1147
mar  

Hi ubzen,

yes, I am learning to program. But it could have been that a script like this already exists and that somebody could upload it here.

But nevertheless thank you for the advice, I will try my best to create a script.

Ubzen
5394
Ubzen  
mar: Hi ubzen, yes, I am learning to program. But it could have been that a script like this already exists and that somebody could upload it here. But nevertheless thank you for the advice, I will try my best to create a script.
This type of question usually translate to "having someone else do the searching for you". I'm just telling you how we interpret it ... nothing personal. I could probably find one for you should I try looking hard enough.
mar
1147
mar  
Ok, I understand how it could be interpreted. But my intention was to ask if this is generally possible to do it with a script. Google found nothing with sense with the keywords "mq4 script line color change". But now I know that it is possible and I think I could create it.
Ubzen
5394
Ubzen  
mar: Ok, I understand how it could be interpreted. But my intention was to ask if this is generally possible to do it with a script. Google found nothing with sense with the keywords "mq4 script line color change". But now I know that it is possible and I think I could create it.
Cool :)
mar
1147
mar  

Obviously not as easy as I thought. But maybe you can give me a tip?

It is not important for me what kind of line it is. I just look for every object and set the color to Lime. But when I drag this script into the chart the lines become black. I have no idea why because I don't see a logical problem. Could it be wrong syntax? But the function ObjectSet() is not so difficult to understand. So I have no idea where the problem is... :-/

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   for(int iObj = ObjectsTotal() - 1; iObj >= 0; iObj--)
    {
      string ObjName = ObjectName(iObj);
      ObjectSet(ObjName, OBJPROP_COLOR, "Lime");
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+
Ubzen
5394
Ubzen  
mar: Obviously not as easy as I thought. But maybe you can give me a tip?

It is not important for me what kind of line it is. I just look for every object and set the color to Lime. But when I drag this script into the chart the lines become black. I have no idea why because I don't see a logical problem. Could it be wrong syntax? But the function ObjectSet() is not so difficult to understand. So I have no idea where the problem is... :-/


mar
1147
mar  

Thanks!! It works now! :)

*PROUD* :D

Ubzen
5394
Ubzen  
mar:

Thanks!! It works now! :)

*PROUD* :D

Cha .. I bet you are :)
mar
1147
mar  

Hi ubzen,

I don't wanted to open a new thread for that because we were just "talking" about objects.. I would like to color the distance between two moving averages.

For example, I use the EMA20 and the EMA50. When the EMA20 is above the EMA50 I want the space between them colored in green, other wise in red.

Do I have to do this with objects or with buffers? I have no idea what to use now. I am pretty sure that I find an indicator like this but I would like to program it myself.

Therefore I would appreciate it, if you tell me what to use. Then I know in which "direction" I have to think.

Thank you!!

123
To add comments, please log in or register