Error 4204

 

Error 4204

I am looking to create an indicator that will create labels to display current pricing details on a chart. However, error 4204 (ERR_OBJECT_GETDATE_FAILED) occurs when adding this indicator to the chart. Can someone help debug this?

---

int OnCalculate(...

{

  string label[5][2];
   label[0,0] = "Market";
   label[0,1] = "Market sentiment...";
   label[1,0] = "Ask";
   label[1,1] = "Bid, ask, and spread...";
   label[2,0] = "Open";
   label[2,1] = "'Open, high, low, and close...";
   label[3,0] = "Volume";
   label[3,1] = "Current and average volume...";
   label[4,0] = "Change";
   label[4,1] = "Price change...";
  
   for (int i = 0; i < ArraySize(label); i++)
   {
      if (ObjectFind(label[i,0]) < 0)
      {
         CreateLabel(label[i,0],label[i,1],x,y);
      }
      else
      {
         ObjectSetString(ChartID(),label[i,0],OBJPROP_TEXT,label[i,1]);
      }
   }

}

bool CreateLabel(string pattern, string text, int x=0, int y=0, color clr=clrBlack, ENUM_BASE_CORNER corner=CORNER_RIGHT_UPPER, ENUM_ANCHOR_POINT anchor=ANCHOR_RIGHT_UPPER)
{
   bool result = false;
   if (ObjectCreate(ChartID(),pattern,OBJ_LABEL,0,0,0) == true)
   {
         ObjectSet(pattern,OBJPROP_CORNER,corner);
         ObjectSet(pattern,OBJPROP_COLOR,clr);
         ObjectSet(pattern,OBJPROP_ANCHOR,anchor);
         ObjectSet(pattern,OBJPROP_BACK,0);
         ObjectSet(pattern,OBJPROP_XDISTANCE,x);
         ObjectSet(pattern,OBJPROP_YDISTANCE,y);
         ObjectSet(pattern,OBJPROP_FONTSIZE,7);
         ObjectSetString(ChartID(),pattern,OBJPROP_FONT,"Arial");
         ObjectSetString(ChartID(),pattern,OBJPROP_TEXT,text);
         result = true;
   }
   else
   {
      result = false;
   }
   return(result);
}

---

Thank you in advance.

 
deltatangoxray: 4204 (ERR_OBJECT_GETDATE_FAILED)
  1. When you post code please use the SRC button! Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum

  2. string label[5][2];
       label[0,0] = "Market";
       label[0,1] = "Market sentiment...";
    I would make the code self documenting by using an array of a structure.
    struct Label{ string name, text; ... 
       void init(string n, string t)
    }
    Label label[5];
       label[0].name = "Market";
       label[0].text = "Market sentiment...";
    
       label[1].init("Ask", "Bid, ask, and spread...");
  3. No idea. Are you sure the error is in that part of the code? Add a Print before and after the section and find out.
 
deltatangoxray:

Error 4204

I am looking to create an indicator that will create labels to display current pricing details on a chart. However, error 4204 (ERR_OBJECT_GETDATE_FAILED) occurs when adding this indicator to the chart. Can someone help debug this?

Thank you in advance.

Not sure where you check you error code, for mql4 it is  :

4204

ERR_NO_OBJECT_NAME

No object name


And please post all the relevant code if you need help.
Runtime Errors - Codes of Errors and Warnings - Standard Constants, Enumerations and Structures - MQL4 Reference
Runtime Errors - Codes of Errors and Warnings - Standard Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
The GetLastError() function return last error code, stored in _LastError predefined variable. This value can be reset using the ResetLastError() function. Error code constants defined at stderror.mqh file. To print text messages use ErrorDescription() function defined at stdlib.mqh file.
 
Alain Verleyen:

Not sure where you check you error code, for mql4 it is  :

4204

ERR_NO_OBJECT_NAME

No object name


And please post all the relevant code if you need help.

Maybe it is MQL5 Code (or the OP checked under MQL5 Error codes). Can't really tell from what was submitted if it is MQL4 or MQL5 code.

ERR_OBJECT_GETDATE_FAILED

4204

Unable to get date corresponding to the value


EDIT: Text is no longer valid as it has been confirmed that the OP's code is indeed MQL4 !
 
Fernando Carreiro:

Maybe it is MQL5 Code (or the OP checked under MQL5 Error codes). Can't really tell from what was submitted if it is MQL4 or MQL5 code.

ERR_OBJECT_GETDATE_FAILED

4204

Unable to get date corresponding to the value



It's mql4 code or it will not compile. There is no ObjectSet() function in mql5.

 
Alain Verleyen: It's mql4 code or it will not compile. There is no ObjectSet() function in mql5.
Correct! Did not notice that. Thanks!
Reason: