Помогите нубу разобраться с ошибкой в коде MQL4 (не происходит запись в массив)

 

Пробуя написать свой индикатор, столкнулся с проблемой: не происходит запись в булевый массив. При этом запись в массив, назначенный индикаторному буферу, происходит отлично. Почему так происходит и что с этим делать?

Запись на Ст.80, объявлен на Ст.20.

//+------------------------------------------------------------------+
//|                                Simple Eliot Structure Finder.mq4 |
//|                                                          Ugarich |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Ugarich"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Lime
//--- buffers
double Indicator0[];

///////////////////////////////////////////////////////////////////////////// <Variables>
//--- extern variables (user input)
extern int EVBarsCount=200; //>=1 for normal work <<Cycle 001>>
//--- variables
bool FirstPoint;
bool ExtrHere[];
//--- code
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ </Variables>

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()/////////////////////////////////////////////////////////////////// <init function>
  {
//---- indicators
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,Indicator0);
//----
   return(0);
  }//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ </init function>
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()///////////////////////////////////////////////////////////////// <deinit function>
  {
//----
   
//----
   return(0);
  }//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ </deinit function>
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()////////////////////////////////////////////////////////////////// <start function>
  {
//var  
   int    counted_bars=IndicatorCounted();
   int i, j, lxext;
   bool fmode, FirstInt, ExtrIsMax[];//-->>..................................... //if fmod==true, then local maximum, else local minimum
   double k, b, x, y, lx, ly;
//init
   for(i=0; i<=Bars; i++) {
      ExtrHere[i]=0;    
      ExtrIsMax[i]=0;  
      Indicator0[i]=0;
   }
//begin  
  i=0;
  while (true){
   if (Open[i]>Close[i]) {                                                
    fmode=true;
    break;
   } else if (Open[i]<Close[i]) {                                                
    fmode=false;
    break;
   }
  i++; 
  }
  
  for(i=1;i<Bars;i++) {
     if (fmode==true){
        if (High[i-1]<=High[i] && High[i]>=High[i+1]){                     //Detection! Extrem (Max) Here
//----------------------------------------------------------------------------------------------------------------------------------------------
           ExtrHere[i]=1;                                                  //Алгоритм поиска правильный, не происходит запись в массив ExtrHere;
//----------------------------------------------------------------------------------------------------------------------------------------------           
           ExtrIsMax[i]=fmode;
           //Alert("Max ", i, "; ", High[i-1], "; ", High[i], "; ", High[i+1], "; ", ExtrHere[i], "; ", ExtrIsMax[i]);           
           //Indicator0[i]=High[i];
           fmode=false;
        }
     } else {
        if (Low[i-1]>=Low[i] && Low[i]<=Low[i+1]){                         //Detection! Extrem (Mix) Here
           ExtrHere[i]=0;
           ExtrIsMax[i]=fmode;
           //Alert("Min ", i, "; ", Low[i-1], "; ", Low[i], "; ", Low[i+1], "; ", ExtrHere[i], "; ", ExtrIsMax[i]);                      
           //Indicator0[i]=Low[i];
           fmode=true;
        }        
     }   
  }//end for
   
  for(i=0;i<Bars;i++) {
     if (ExtrHere[i]==1) {
        if (ExtrIsMax[i]==1) {
           Indicator0[i]=High[i];
        } else {
           Indicator0[i]=Low[i];
        }
     } else {
        Indicator0[i]=0;
     }
  }

  //Alert(Indicator0[0], "; ", Indicator0[1], "; ", Indicator0[2], "; ", Indicator0[3], "; ", Indicator0[4], "; ", Indicator0[5], " ;", Indicator0[6]);

   return(0);
  }//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ </start function>
//+------------------------------------------------------------------+
 
Установите размер массива и проинициализируйте его.
 

Спасибо, все заработало!

Добавил следующие строчки со Ст.58 (перед циклом for в разделе //init функции start):

  tmplength=ArrayRange(Low, 0);
  ArrayResize(ExtrHere, tmplength);
  ArrayResize(ExtrIsMax, tmplength);
Причина обращения: