Delay when handling chart events

 

I have a test script that just draws a couple of HLines in the chart when pressing a keyboard key, any key (just for testing). Something like this:

void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam) {

    if(id==CHARTEVENT_KEYDOWN){ 

         drawHLines_test( );
    } 
}

Inside drawHLines_test just have basic code to draw HLines, nothing fancy, something like this:

line1.Create(0, label1, 0, price1);
line1.Color(color1);
line1.Style(STYLE_DASHDOT);

While this seems to work fine, I have noticed that after pressing the key, the lines appear only after the next "tick"...not immediately after pressing the key, as I would expect.

I have read somewhere else, and also tried adding ChartRedraw() right after drawing the lines, still this does not seem to work.

Is it something wrong here that I am missing?

 
Use ChartRedraw().
 
Alain Verleyen #Use ChartRedraw().
Please read my complete question, it is in bold letters.
 
Pedro Sanchez #:
Please read my complete question, it is in bold letters.

Use ChartRedraw() correctly.

And post all the relevant code when you need coding help.