OnDeinit ObjectDelete not when market is closed

To add comments, please log in or register
samjesse
645
samjesse  

Hi

When market is closed the code below failed to remove an object from the chart.

How can I fix it so that IndicatorList > "select the indicator in question" > Delete works by deleting the object which was created?

because now I am getting "1 undeleted objects left" in the Expert log.


Also, when the market is open, the object gets deleted ONLY when a tick is received.


Thanks


string pipValueLabel = "pipValueLabel";

int OnInit() {
   if(isPipValueCreate) createPipValueLabel();
  
   return(INIT_SUCCEEDED);
  
}

void OnDeinit(const int reason) { 
 
  ObjectDelete(0, pipValueLabel); 

}
void createPipValueLabel(){
  if(ObjectCreate(0,pipValueLabel,OBJ_LABEL,0,0,0))
    {
    ObjectSetInteger(0,pipValueLabel,OBJPROP_CORNER,CORNER_LEFT_UPPER);
    ObjectSetInteger(0,pipValueLabel,OBJPROP_COLOR,labelColor);
    ObjectSetInteger(0,pipValueLabel,OBJPROP_XDISTANCE,5);
    ObjectSetInteger(0,pipValueLabel,OBJPROP_YDISTANCE,20);
    ObjectSetString(0,pipValueLabel,OBJPROP_TEXT,DoubleToString(pipValue(Symbol(), accountCurrency),2));
    }
  else
    Print("Failed to create the object OBJ_LABEL ",pipValueLabel,", Error code = ", GetLastError());
}
kypa
981
kypa  
ChartRedraw()
To add comments, please log in or register