Download MetaTrader 5

Is there a way to program color changes on the chart?

To add comments, please log in or register
Millions of traders download codes from MQL5 library. Share your app with them!
Donald Gibson
498
Donald Gibson 2016.01.13 09:18 

I have searched google and the MQL's but I cant find any examples on how to change the colors of the axis, scale, etc.

I would like to cahnge the according what order is open.

red for sell,green for buy,blue for no orders.

honest_knave
Moderator
2199
honest_knave 2016.01.13 09:26  

You need to use:

ChartSetInteger(0,CHART_COLOR_FOREGROUND, myColor);

 Run a loop through your open orders, figure out what color you want the axes to be, then set the color using the above code.

Donald Gibson
498
Donald Gibson 2016.01.13 09:54  
honest_knave:

You need to use:

 Run a loop through your open orders, figure out what color you want the axes to be, then set the color using the above code.

i tried that but it only changed the foreground colors on the chart. i wish to change the color of the price scale, axis, period separators,etc just like i can do in the options menu
honest_knave
Moderator
2199
honest_knave 2016.01.13 10:10  

I just dropped this script on a chart:

void OnStart()
  {
   ChartSetInteger(0,CHART_COLOR_FOREGROUND, clrPink);
  }

 

And ended up with this:

 

Donald Gibson
498
Donald Gibson 2016.01.13 10:14  
honest_knave:

I just dropped this script on a chart:

 

And ended up with this:

 

hmmm i am not getting it to do that. 

i am trying to use this in a ea, would that matter? 

honest_knave
Moderator
2199
honest_knave 2016.01.13 10:22  
4x_Gypsy:

hmmm i am not getting it to do that. 

i am trying to use this in a ea, would that matter? 

Shouldn't do. I just dropped this EA onto a chart with the same effect

void OnTick()
  {
   ChartSetInteger(0,CHART_COLOR_FOREGROUND, clrPink);
  }
Donald Gibson
498
Donald Gibson 2016.01.13 10:25  
honest_knave:

Shouldn't do. I just dropped this EA onto a chart with the same effect

 

i have got it running through a loop under ontick. i place the trades with a button, ea doesnt make any trades at all it is a manual assistant.

if i take ChartSetInteger(0,CHART_COLOR_FOREGROUND,clrBlue); out of the loop it works fine but in the loop it doesnt.

Donald Gibson
498
Donald Gibson 2016.01.13 10:40  

got it fixed.

i put ChartSetInteger(0,CHART_COLOR_FOREGROUND,clrGreen) in the  buy function and so on, it works great.

But it still will not work in a loop, 

Thank you for you're guidance.

Have a wonderful and profitable day 

honest_knave
Moderator
2199
honest_knave 2016.01.13 15:05  
Likewise, glad you got it sorted
To add comments, please log in or register