Please help I am trying to create an array for ratio but I receive an error

 
2018.06.05 19:42:23.176 2016.03.01 00:03:30   array out of range in 'Ratio expert advisor.mq5' (54,20)
void OnTick()
  {
//---
   double Varience;
   double ChartArray[];
   double TheOtherCurrencyPairArray[];
   double RatioArray[];
   
   ArraySetAsSeries(TheOtherCurrencyPairArray,true);
   ArraySetAsSeries(ChartArray,true);
     
   CopyClose(Symbol(),time,0,lookbackperiod-1,ChartArray);
   CopyClose(TheOtherCurrencyPair,time,0,lookbackperiod-1,TheOtherCurrencyPairArray);
  
   
   
   for(int x= 0; x<lookbackperiod;x++)
      {
        double k  = ChartArray[x]/TheOtherCurrencyPairArray[x];
         RatioArray[x]= k;
      }
    
   Varience = MathVariance(RatioArray);
   

   
  
   
  }
//+------------------------------------------------------------------+

 
17003821:
2018.06.05 19:42:23.176 2016.03.01 00:03:30   array out of range in 'Ratio expert advisor.mq5' (54,20)

You need to set the size of the array.

Look at the ArrayResize() function.

 
Anthony Garot:

You need to set the size of the array.

Look at the ArrayResize() function.

Thank you very much for your assistence, very sorry to trouble you where and how exactly do I resize the array.
 
17003821:
Thank you very much for your assistence, very sorry to trouble you where and how exactly do I resize the array.
   if ( ArrayResize(RatioArray,lookbackperiod-1) == -1 ) { Print("Failed to resize"); }

   for(int x=0; x<lookbackperiod - 1;x++)
     {
      double k=ChartArray[x]/TheOtherCurrencyPairArray[x];
      RatioArray[x]=k;
     }
 
Before you assign values to it.
 
Marco vd Heijden:
Before you assign values to it.

Thank you very much