Custom made indicator not working

 

Hello all.

I have written a simple indicator that should plot labels on chart.

When I compile it, it returns no errors.

But when I load it on the chart, it does not display the labels and it is removed without errors.


I cannot understand what I am doing wrong, could someone please help me find the error(s)?

TIA.

F.


//+------------------------------------------------------------------+
//                                             Label Generator v1.00 |
//+------------------------------------------------------------------+
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
input bool ShowLabels=true;
input string FontType="Arial";
input int FontSize=8;
input color FontColor=clrGray;
input int XCornerDistance=10;
input int YCornerDistance=10;
string array_labels_text[];
string object_adder="ADDER";
//+------------------------------------------------------------------+
int init()
 {
  int z=0;
  if(ShowLabels)
   {
    array_labels_text[z++]="LABEL CREATOR 1.0";
    array_labels_text[z++]="";
    array_labels_text[z++]="TBD";
    for(int i=0; i<=z; i++)
     {
      LabelCreate(0,                      // chart_ID
                  object_adder+string(i), // name
                  0,                      // sub_window
                  XCornerDistance,        // x
                  i*YCornerDistance,      // y
                  CORNER_RIGHT_UPPER,     // corner
                  array_labels_text[i],   // text
                  FontType,               // font
                  FontSize,               // font size
                  FontColor,              // color
                  ANCHOR_RIGHT_UPPER      // anchor
                  //1?                    // back
                  //1?                    // hidden
                 );
     }
    }
  return(0);
 }
//+------------------------------------------------------------------+
int start()
 {
  return(0);
 }
//+------------------------------------------------------------------+
int deinit()
 {
  string name;
  int obj_total=ObjectsTotal();
  for(int i=obj_total-1; i>=0; i--)
   {
    name=ObjectName(i);
    if(StringFind(name,"LABEL_")==0)
     ObjectDelete(name);
   }
  return(0);
 }
//+------------------------------------------------------------------+
bool LabelCreate(const long              chart_ID=   0,
                 const string            name=       "LABEL_",
                 const int               sub_window= 0,
                 const int               x=          10,
                 const int               y=          10,
                 const ENUM_BASE_CORNER  corner=     CORNER_RIGHT_UPPER,
                 const string            text=       "Label",
                 const string            font=       "Arial",
                 const int               font_size=  8,
                 const color             clr=        clrGray,
                 const ENUM_ANCHOR_POINT anchor=     ANCHOR_RIGHT_UPPER,
                 const bool              back=       false,
                 const bool              hidden=     false)
 {
  ObjectDelete(0,name);
  if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
   {
    Print(__FUNCTION__," : Error = ",GetLastError());
     return(false);
   }
  ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
  ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
  ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
  ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
  ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
  ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
  ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,0);
  ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
  ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
  ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
  ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,false);
  ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,false);
  ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
  return(true);
 }
//+------------------------------------------------------------------+
 
Look in the journal tab and you will see your why — Array exceeded.
string array_labels_text[];
⋮
    array_labels_text[z++]=…
 

Thank you sir.

William Roeder:
Look in the journal tab and you will see your why — Array exceeded.