Object delay

 

hi

i made a OBJ_BUTTON that if i push im it will show at other OBJ_BUTTON the current Ask

but sometimes there is a delay of couple second untill he show me the Ask

why there is a delay ? 


//+------------------------------------------------------------------+
//|                                                  Panel.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"


int box_h=25;
int font_size=12;
 
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
      
   creatbottom();

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---

   
   if(id==CHARTEVENT_OBJECT_CLICK & sparam=="Stop_Loss"   )
   {
      double Ask=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
      ObjectSetString(_Symbol,"Stop_Loss_Edit",OBJPROP_TEXT,Ask);
   }
   

  }
//+------------------------------------------------------------------+

void creatbottom()
{  
      int chart_ID=0;
      string name7="Stop_Loss"; 
      if(!ObjectCreate(0,name7,OBJ_BUTTON,0,0,0)) 
        { 
         Print(__FUNCTION__, 
               ": failed to create the sell button! Error code = ",GetLastError()); 
         return; 
        } 
   //--- set button coordinates 
      ObjectSetInteger(chart_ID,name7,OBJPROP_XDISTANCE,000); 
      ObjectSetInteger(chart_ID,name7,OBJPROP_YDISTANCE,150); 
   //--- set button size 
      ObjectSetInteger(chart_ID,name7,OBJPROP_XSIZE,100); 
      ObjectSetInteger(chart_ID,name7,OBJPROP_YSIZE,box_h); 
   //--- set the chart's corner, relative to which point coordinates are defined 
      ObjectSetInteger(chart_ID,name7,OBJPROP_CORNER,0); 
   //--- set the text 
      ObjectSetString(chart_ID,name7,OBJPROP_TEXT,"SL");
   //--- set text font 
      ObjectSetString(chart_ID,name7,OBJPROP_FONT,"Ariel"); 
   //--- set font size 
      ObjectSetInteger(chart_ID,name7,OBJPROP_FONTSIZE,font_size); 
   //--- set text color 
      ObjectSetInteger(chart_ID,name7,OBJPROP_COLOR,clrYellow); 
   //--- set background color 
      ObjectSetInteger(chart_ID,name7,OBJPROP_BGCOLOR,clrBlue); 
   //--- set border color 
      ObjectSetInteger(chart_ID,name7,OBJPROP_BORDER_COLOR,clrBlack); 
   //--- display in the foreground (false) or background (true) 
      ObjectSetInteger(chart_ID,name7,OBJPROP_BACK,false); 
   //--- set button state 
      ObjectSetInteger(chart_ID,name7,OBJPROP_STATE,false); 
   //--- enable (true) or disable (false) the mode of moving the button by mouse 
      ObjectSetInteger(chart_ID,name7,OBJPROP_SELECTABLE,false); 
      ObjectSetInteger(chart_ID,name7,OBJPROP_SELECTED,false); 
   //--- hide (true) or display (false) graphical object name in the object list 
      ObjectSetInteger(chart_ID,name7,OBJPROP_HIDDEN,true); 
   //--- set the priority for receiving the event of a mouse click in the chart 
      ObjectSetInteger(chart_ID,name7,OBJPROP_ZORDER,0); 
   //--- successful execution            

//------------- Stop_Loss_Edit  

      string name8="Stop_Loss_Edit"; 
      if(!ObjectCreate(0,name8,OBJ_EDIT,0,0,0)) 
        { 
         Print(__FUNCTION__, 
               ": failed to create the sell button! Error code = ",GetLastError()); 
         return; 
        } 
   //--- set button coordinates 
      ObjectSetInteger(chart_ID,name8,OBJPROP_XDISTANCE,100); 
      ObjectSetInteger(chart_ID,name8,OBJPROP_YDISTANCE,150); 
   //--- set button size 
      ObjectSetInteger(chart_ID,name8,OBJPROP_XSIZE,100); 
      ObjectSetInteger(chart_ID,name8,OBJPROP_YSIZE,box_h); 
   //--- set the chart's corner, relative to which point coordinates are defined 
      ObjectSetInteger(chart_ID,name8,OBJPROP_CORNER,0); 
   //--- set the text 
      ObjectSetString(chart_ID,name8,OBJPROP_TEXT,"0");
   //--- set text font 
      ObjectSetString(chart_ID,name8,OBJPROP_FONT,"Ariel"); 
   //--- set font size 
      ObjectSetInteger(chart_ID,name8,OBJPROP_FONTSIZE,font_size); 
   //--- set text color 
      ObjectSetInteger(chart_ID,name8,OBJPROP_COLOR,clrBlack); 
   //--- set background color 
      ObjectSetInteger(chart_ID,name8,OBJPROP_BGCOLOR,clrWhite); 
   //--- set border color 
      ObjectSetInteger(chart_ID,name8,OBJPROP_BORDER_COLOR,clrBlack); 
   //--- display in the foreground (false) or background (true) 
      ObjectSetInteger(chart_ID,name8,OBJPROP_BACK,false); 
   //--- set button state 
      ObjectSetInteger(chart_ID,name8,OBJPROP_STATE,false); 
   //--- enable (true) or disable (false) the mode of moving the button by mouse 
      ObjectSetInteger(chart_ID,name8,OBJPROP_SELECTABLE,false); 
      ObjectSetInteger(chart_ID,name8,OBJPROP_SELECTED,false); 
   //--- hide (true) or display (false) graphical object name in the object list 
      ObjectSetInteger(chart_ID,name8,OBJPROP_HIDDEN,true); 
   //--- set the priority for receiving the event of a mouse click in the chart 
      ObjectSetInteger(chart_ID,name8,OBJPROP_ZORDER,0); 
   //--- successful execution  
             
}
 

Don't know if it will make any difference but you can try using

ChartRedraw();

After you modify the object.

 
Keith Watford:

Don't know if it will make any difference but you can try using

After you modify the object.

yeah is help

thank you bro !

Reason: