My Error : { array out of range in 'Expert' (117,46) }

 
//+------------------------------------------------------------------+
//|                                                        Expert.mq5|
//|                                   Copyright 2023, MetaQuotes Ltd.|
//|                                              https://www.mql5.com|
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//--- 
//+------------------------------------------------------------------+
//|Giving data from the indicator                                    |
//+------------------------------------------------------------------+
double Open[], High[], Low[], Close[];

ArraySetAsSeries(Open,true);
ArraySetAsSeries(High,true);
ArraySetAsSeries(Low,true);
ArraySetAsSeries(Close,true);

int CyznerHandle = iCustom(Symbol(),PERIOD_H4,"Examples\\ARKA-Cyzner Sauce");

CopyBuffer(CyznerHandle,0,0,55,Open);
CopyBuffer(CyznerHandle,1,0,55,High);
CopyBuffer(CyznerHandle,2,0,55,Low);
CopyBuffer(CyznerHandle,3,0,55,Close);

//+------------------------------------------------------------------+
//|Recognize the BOX                                                 |
//+------------------------------------------------------------------+  
int Xcount = 0;
   for(int count = 0; count < 51; count++)//***
{
double CyznerClose = NormalizeDouble(Close[count],Digits());
if(CyznerClose != 0) break;
Xcount = count;
}   

//+....................................................................
 
MqlRates rates[]; 
   ArraySetAsSeries(rates,true); 
   int copiedCandel = CopyRates(Symbol(),PERIOD_H4,0,100,rates); 
   
//+....................................................................

double Candel1Open = rates[Xcount].open;
double Candel1Close = rates[Xcount].close;


int NUMBEROFEND = 0; 
int boxnotavailable =0;
if(Candel1Open < Candel1Close)  //Bullish
{
   for(int Num1Ca = Xcount - 1; Num1Ca >= 0; Num1Ca--)
  {  
    double Candel2Open = rates[Num1Ca].open;
    double Candel2Close = rates[Num1Ca].close;
           
            if(Candel2Open > Candel2Close) break; //Bearish
                           
              for(int Num2Ca = Num1Ca - 1; Num2Ca >= 0; Num2Ca--)
                 {  
                    double Candel3Open = rates[Num2Ca].open;
                    double Candel3Close = rates[Num2Ca].close;
                    
                           if(Candel3Open < Candel3Close) break;  //Bullish
                           NUMBEROFEND = Num2Ca;
                 }
                 
   }
} 
   
else if(Candel1Open > Candel1Close) //Bearish
{
   for(int Num11Ca = Xcount - 1; Num11Ca >= 0; Num11Ca--)
  {  
       double Candel2Open = rates[Num11Ca].open;
       double Candel2Close = rates[Num11Ca].close;
          
      if(Candel2Open < Candel2Close) break;  //Bullish         
         
         for(int Num22Ca = Num11Ca - 1; Num22Ca >= 0; Num22Ca--)
             {  
               double Candel3Open = rates[Num22Ca].open;
               double Candel3Close = rates[Num22Ca].close;

                      if(Candel3Open > Candel3Close) break;  //Bearish
                       NUMBEROFEND = Num22Ca; 
             }
             
    }
}   

else 
boxnotavailable = 1;
   
int COMPNUMBEROFEND = NUMBEROFEND -1;


//+.....................................................
int LengthBox = ((Xcount - 1) - COMPNUMBEROFEND) + 1;
//+.....................................................

//+------------------------------------------------------------------+
//|Find the highest and lowest box prices                            |
//+------------------------------------------------------------------+  

int HighestBox_index = iHighest(Symbol(),PERIOD_H4,MODE_HIGH,LengthBox,COMPNUMBEROFEND);
int LowestBox_index = iLowest(Symbol(),PERIOD_H4,MODE_LOW,LengthBox,COMPNUMBEROFEND);

double CandelBoxHigh = NormalizeDouble(rates[HighestBox_index].high,Digits());
double CandelBoxLow = NormalizeDouble(rates[LowestBox_index].low,Digits());
 
  }

I will be grateful for your help

 
void OnTick(){
⋮
int CyznerHandle = iCustom(Symbol(),PERIOD_H4,"Examples\\ARKA-Cyzner Sauce");
CopyBuffer(CyznerHandle,0,0,55,Open);
  1. Perhaps you should read the manual, especially the examples.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
              Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
              Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
              How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
              How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
              MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
              How to call indicators in MQL5 - MQL5 Articles (2010)

  2. Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), 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. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

 
William Roeder #:
  1. Perhaps you should read the manual, especially the examples.
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

    They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
              Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
              Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
              How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
              How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
              MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
              How to call indicators in MQL5 - MQL5 Articles (2010)

  2. Don't try to use any price (or indicator) or server related functions in OnInit (or on load or in OnTimer before you've received a tick), 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. A new tick is received, OnCalculate/OnTick is called. Now TickValue, TimeCurrent, account information and prices are valid.

Thank you for your help and advice