Please help for the error "array out of range" in my program.

 

I get an error saying: "array out of range"


I am new to coding and MQL5 so I am trying to understand the basics.



#property copyright "Copyright 2021, NENFB LLC"
#property link      "https://www.NENFBLLC.com"
#property version   "2.00"

//-------------------------------------------------------------------------

// Initialized Variables

double upper_band = 62.50;
double mid_upper_band = 56.25;
double mid_lower_band = 43.75;
double lower_band = 37.50;
int mid_rsi = 50; 

input int ma_period = 42;

int handle;


int OnInit()
  {
   handle = iRSI(_Symbol,PERIOD_CURRENT,42,PRICE_OPEN);
   
   Print("OnInit...");
   return(INIT_SUCCEEDED);
  }

//-------------------------------------------------------------------------

void OnDeinit(const int reason)
  {

   Print("OnDeinit...");
   
  }

//-------------------------------------------------------------------------

void OnTick()
  {
   
   double rsi[];
   ArrayResize(rsi,10000,10000);
   
   CopyBuffer(handle,0,1,2,rsi);
   
   if(rsi[0] < mid_rsi && rsi[2] < lower_band && rsi[1] < lower_band && rsi[0] > lower_band){
      Print("Buy Signal");
   }else if(rsi[0] > mid_rsi && rsi[2] > upper_band && rsi[1] > upper_band && rsi[0] < upper_band){
      Print("Sell Signal");
   }
   
     
  }
  
  
 
   CopyBuffer(handle,0,1,2,rsi);
   
   if(rsi[0] < mid_rsi && rsi[2] 
You copied two values. The array has therefor indexes [0 … 1]. Why does your attempt at accessing index two, surprise you?
 
Quantfoundation:

I get an error saying: "array out of range"


I am new to coding and MQL5 so I am trying to understand the basics.



Replace rsi[2] to rsi[1].

 
Quantfoundation:

I get an error saying: "array out of range"


I am new to coding and MQL5 so I am trying to understand the basics.



Are you available for private code consult and audit?
 
Thank you very much for these great cake recipes, I have learned a lot from you web bloeru temple run