array out of range problem

 
double   BodyStick[];
double   AboveWick[];
double   BelowWick[];

void OnTick()
   {
   Candle_update();
   }
void Candle_update()
   {
   int i;
   for(i=0; i<10; i++)
      {
      BodyStick[i] = 1;
      AboveWick[i] = 1;
      BelowWick[i] = 1;
      }
   }
My code is something like above, no matter how I input on the BodyStick[i] or the condition for i, when I put the EA on the platform, it escaped in a tick and return "array out of range" (the line of BodyStick[i], 16) What's wrong and how can I fix this? Thanks for any help.
The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks, as a small error in the expert or indicator logic can cause losses on the trading account. That is why we have developed a series of basic checks to ensure the required quality level of the Market products. If any errors are identified by the Market...
 
Hiệp Lê :
My code is something like above, no matter how I input on the BodyStick[i] or the condition for i, when I put the EA on the platform, it escaped in a tick and return " array out of range " (the line of BodyStick[i], 16) What's wrong and how can I fix this? Thanks for any help.

You made a gross mistake: You have declared a DYNAMIC array. You MUST manage the size of the array yourself.

ArrayResize

Documentation on MQL5: Array Functions / ArrayResize
Documentation on MQL5: Array Functions / ArrayResize
  • www.mql5.com
If ArrayResize() is applied to a static array, a timeseries or an indicator buffer, the array size remains the same – these arrays will not be reallocated. In this case, if The function can be applied only to dynamic arrays. It should be noted that you cannot change the size of dynamic arrays assigned as indicator buffers by the...
 
Vladimir Karputov:

You made a gross mistake: You have declared a DYNAMIC array. You MUST manage the size of the array yourself.

ArrayResize

Thanks for help, I resized the array and it works.