Array out of range

 

Whats my problem?

input int cn=100;
double lowP[];
void OnInit()
  {
   for(int i=1;i<=cn;i++)
     {
      lowP[i-1]=iLow(Symbol(),60,i);
     }
     Comment(lowP[0],"\n",lowP[1],"\n",lowP[2]); 
  }

show this!

Files:
qaz.png  6 kb
 
ArrayResize(lowP,cn);
 
  1. Emad E: Whats my problem?

    Obviously you can't read. The image clearly states "array out of range"

  2. double lowP[];
    Array has no size, you can't store into it.
  3. void OnInit(){
       ⋮
       … iLow(Symbol(),60,i);
    Don't try to use any price or server related functions in OnInit (or on load), as there may be no connection/chart yet:
    1. Terminal starts.
    2. Indicators/EAs are loaded. Static and globally declared variables are initialized. (Do not depend on a specific order.)
    3. OnInit is called.
    4. For indicators OnCalculate is called with any existing history.
    5. Human may have to enter password, connection to server begins.
    6. New history is received, OnCalculate called again.
    7. New tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.
Reason: