delay in running in event handling

 

hi guys

I wrote some code to move vertical line by keyboard( number 4 for backward & number 6 for forward)

it is correct but it has delay every time I press bottom.

how can I overcome this issue?

(sorry for my bad english)

void OnChartEvent(const int EventID,const long& lparam,const double& dparam,const string& sparam)
{        
   datetime base=ObjectGetInteger(0,"Line",OBJPROP_TIME,0);
   
   if(EventID == CHARTEVENT_KEYDOWN )
   {
      short KeyThatWasPressed = TranslateKey((int)lparam);
      if(ShortToString(KeyThatWasPressed)=="6")
      {
         
         ObjectMove(_Symbol,"Line",0,base+PeriodSeconds(),0);

      }
      else if(ShortToString(KeyThatWasPressed)=="4")
      {
         ObjectMove(_Symbol,"Line",0,base-PeriodSeconds(),0);
      }
   }
}
 
naweeeeed:

hi guys

I wrote some code to move vertical line by keyboard( number 4 for backward & number 6 for forward)

it is correct but it has delay every time I press bottom.

how can I overcome this issue?

(sorry for my bad english)

Metatrader 4 or 5? On 5 calls to ObjectMove are not synchronous.
 
 

Thanks a lot

ChartRedraw was my answer.

I didn't know that was asynchronous.

Reason: