[Solved] CHART_BRING_TO_TOP - How run Quickly - How Change Other Graph Fast

 

Hello, I read the documentation about CHART_BRING_TO_TOP, and there it says the following:


The function is asynchronous, that is, it does not wait for the command to be successfully queued for the specified chart to execute, instead it returns control immediately. The property will only change after processing the command in the chart queue.

To immediately execute commands in the schedule queue, you need to call the ChartRedraw function (MQL5)



However, for my case this function runs randomly, sometimes in 0.5 seconds, other times 3.4 seconds.


I'm looking for a way to do this faster.


Update #1

Below is my function to change graph:


   if(!ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true))
     {

      MessageBox("Failed to change chart, error " + GetLastError(), "Failed to change chart", MB_OK);
      return(false);
     }

   ChartRedraw();
Documentation on MQL5: Chart Operations / ChartRedraw
Documentation on MQL5: Chart Operations / ChartRedraw
  • www.mql5.com
ChartRedraw - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Ha-yun: I'm looking for a way to do this faster.

What part of “immediately” was unclear to you?

 
William Roeder #:

What part of “immediately” was unclear to you?

I've tried using ChartRedraw() and it doesn't fulfill a function "immediately".

Are there alternatives to make this quick switch between charts?


Below is my function to change graph:


   if(!ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true))
     {

      MessageBox("Failed to change chart, error " + GetLastError(), "Failed to change chart", MB_OK);
      return(false);
     }

   ChartRedraw();

 
William Roeder #:

What part of “immediately” was unclear to you?

Thank you!

You opened my eyes, the ChartRedraw() function has chart_id as a parameter, and it's the chart you want to inform, that you need, not the current chart.