Errorearray out of range

 
hello everyone, I'm getting the array out of range error with my ea ... Can anyone help me out? Thanks in advance
//+------------------------------------------------------------------+
//|                                                      FirstEA.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#include <Arrays\Array.mqh>
#include <Arrays\ArrayChar.mqh>
#include <Arrays\ArrayDouble.mqh>
#include <Arrays\ArrayFloat.mqh>
#include <Arrays\ArrayInt.mqh>
#include <Arrays\ArrayLong.mqh>
#include <Arrays\ArrayObj.mqh>
#include <Arrays\ArrayShort.mqh>
#include <Arrays\ArrayString.mqh>
#include <Arrays\List.mqh>
#include <Arrays\Tree.mqh>
#include <Arrays\TreeNode.mqh>


double zz[];
double macd[];
double stochastico[];
extern int macdFastEMA=12;   // Fast EMA Period
extern int macdSlowEMA=26;   // Slow EMA Period
extern int macdSignalSMA=9;  // Signal SMA Period
extern int stochasticoKPeriod=5; // K Period
extern int stochasticoDPeriod=3; // D Period
extern int stochasticoSlowing=3; // Slowing
extern int stochasticoipervenduto=20; // Slowing
extern int stochasticoipercomprato=80; // Slowing
bool   displayAlert=false;
double lot;
extern double Rischio=0.001;
extern double tp=1000;
extern double sl=1000;
string comment="liv";

void calcoloindicatori(int i)
{

zz[i]=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,i);
macd[i]=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,i);
stochastico[i]=iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,i);

}

bool Piccozz()
{

if(iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,1)&&
    iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,2)&&
    iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,3))
    return(true);
    else 
     return(false);

}

bool Piccomacd()
{

if((iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,1)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,2)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,3))||
  (iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,1)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,2)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,3)))
   return(true);
   else
    return(false);

}
bool Piccostcconfermato()
{

if(iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)<iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,1)&&
   iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,1)>=iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,2)&&
   iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,2)>=iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,3))
   return(true);
    else 
     return(false);

}

int PicchiPrecedentizz()
  {
     int limit; 
     int counted_bars=IndicatorCounted(); 
  //---- check for possible errors 
     if(counted_bars<0) return(-1); 
  //---- the last counted bar will be recounted 
     if(counted_bars>0) counted_bars--; 
     limit=Bars-counted_bars; 
  //---- main loop 
     for(int i=0; i<limit; i++) 
       { 
       ArrayResize(zz,i,1000);
      if(zz[i]>=zz[i+1] && zz[i] >= zz[i+2] &&
         zz[i] >= zz[i-1] && zz[i] >= zz[i-2])
         return(i);
      }
   return(-1);
}
int PicchiPrecedentimacd()
{
     int limit; 
     int counted_bars=IndicatorCounted(); 
  //---- check for possible errors 
     if(counted_bars<0) return(-1); 
  //---- the last counted bar will be recounted 
     if(counted_bars>0) counted_bars--; 
     limit=Bars-counted_bars; 
  //---- main loop 
     for(int i=0; i<limit; i++) 
       { 
       ArrayResize(macd,i,1000);
      if(macd[i]>=macd[i+1] && macd[i] >= macd[i+2] &&
         macd[i] >= macd[i-1] && macd[i] >= macd[i-2])
         return(i);
      }
   return(-1);
}
int PicchiPrecedentistc()
{
     int limit; 
     int counted_bars=IndicatorCounted(); 
  //---- check for possible errors 
     if(counted_bars<0) return(-1); 
  //---- the last counted bar will be recounted 
     if(counted_bars>0) counted_bars--; 
     limit=Bars-counted_bars; 
  //---- main loop 
     for(int i=0; i<limit; i++) 
       { 
       ArrayResize(stochastico,i,1000);
      if(stochastico[i]>=stochastico[i+1] && stochastico[i] >= stochastico[i+2] &&
         stochastico[i] >= stochastico[i-1] && stochastico[i] >= stochastico[i-2])
         return(i);
      }
   return(-1);

}
bool Minimozz()
{

if(iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,1)&&
    iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,2)&&
    iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,3))
    return(true);
    else 
     return(false);

}

bool Minimomacd()
{

if((iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,1)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,2)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,3))||
  (iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,1)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,2)&&
   iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<=iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,3)))
   return(true);
   else
    return(false);

}
bool Minimostcconfermato()
{

if(iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)>iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,1)&&
   iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,1)<=iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,2)&&
   iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,2)<=iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,3))
   return(true);
    else 
     return(false);

}

int MinimiPrecedentizz()
  {
     int limit; 
     int counted_bars=IndicatorCounted(); 
  //---- check for possible errors 
     if(counted_bars<0) return(-1); 
  //---- the last counted bar will be recounted 
     if(counted_bars>0) counted_bars--; 
     limit=Bars-counted_bars; 
  //---- main loop 
     for(int i=0; i<limit; i++) 
       { 
      if(zz[i]<=zz[i+1] && zz[i] <= zz[i+2] &&
         zz[i] <= zz[i-1] && zz[i] <= zz[i-2])
         return(i);
      }
   return(-1);
}
int MinimiPrecedentimacd()
{
     int limit; 
     int counted_bars=IndicatorCounted(); 
  //---- check for possible errors 
     if(counted_bars<0) return(-1); 
  //---- the last counted bar will be recounted 
     if(counted_bars>0) counted_bars--; 
     limit=Bars-counted_bars; 
  //---- main loop 
     for(int i=0; i<limit; i++) 
       { 
      if(macd[i]<=macd[i+1] && macd[i] <= macd[i+2] &&
         macd[i] <= macd[i-1] && macd[i] <= macd[i-2])
         return(i);
      }
   return(-1);
}
int MinimiPrecedentistc()
{
     int limit; 
     int counted_bars=IndicatorCounted(); 
  //---- check for possible errors 
     if(counted_bars<0) return(-1); 
  //---- the last counted bar will be recounted 
     if(counted_bars>0) counted_bars--; 
     limit=Bars-counted_bars; 
  //---- main loop 
     for(int i=0; i<limit; i++) 
       { 
      if(stochastico[i]<=stochastico[i+1] && stochastico[i] <= stochastico[i+2] &&
         stochastico[i] <= stochastico[i-1] && stochastico[i] <= stochastico[i-2])
         return(i);
      }
   return(-1);
}
string res="void";
void DivergenzaLong()
{
int ticket=-1;
int i;
zz[i]=MinimiPrecedentizz();
stochastico[i]=MinimiPrecedentistc();
macd[i]=MinimiPrecedentimacd();
if(Minimozz()==true&&Minimomacd()==true&&Minimostcconfermato()==true)
{
 if((iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>zz[i]&&
    iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)<stochastico[i])||
    (iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>zz[i]&&iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)<stochastico[i]&&
    iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)<stochasticoipervenduto))
    {
    res="buy";
    ticket=OrderSend(_Symbol,OP_BUY,MM_Size(),Ask,0,Ask-sl*Point,Ask+tp*Point,comment,0,0,clrGreen);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di continuazione Rialzista: ",Symbol());}
    }//end comparing values
  else res="void";

if(iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>zz[i]&&
    iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<=macd[i])
    {
    res="buy";
    ticket=OrderSend(_Symbol,OP_BUY,MM_Size(),Ask,0,Ask-sl*Point,Ask+tp*Point,comment,0,0,clrGreen);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di continuazione Rialzista: ",Symbol());}
    }//end comparing values
  else res="void";
 
if(Minimozz()==true&&Minimomacd()==true&&Minimostcconfermato()==true)
{
 if((iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<zz[i]&&
    iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)>stochastico[i])||
    (iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<zz[i]&&iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)>stochastico[i]&&
    stochastico[i]<stochasticoipervenduto))
    {
    res="buy";
    ticket=OrderSend(_Symbol,OP_BUY,MM_Size(),Ask,0,Ask-sl*Point,Ask+tp*Point,comment,0,0,clrGreen);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di inversone Rialzista: ",Symbol());}
    }//end comparing values
  else res="void";

if(iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<zz[i]&&
    iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>=macd[i])
    {
    res="buy";
    ticket=OrderSend(_Symbol,OP_BUY,MM_Size(),Ask,0,Ask-sl*Point,Ask+tp*Point,comment,0,0,clrGreen);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di inversione Rialzista: ",Symbol());}
     }//end comparing values
      else res="void";
      }
   }
}
void DivergenzaShort()
{
int ticket=-1;
int i;
zz[i]=PicchiPrecedentizz();
stochastico[i]=PicchiPrecedentistc();
macd[i]=PicchiPrecedentimacd();
if(Piccozz()==true&&Piccomacd()==true&&Piccostcconfermato()==true)
{
 if((iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<zz[i]&&
    iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)>stochastico[i])||
    (iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<zz[i]&&iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)>stochastico[i]&&
    iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)>stochasticoipercomprato))
    {
    res="sell";
    ticket=OrderSend(_Symbol,OP_SELL,MM_Size(),Bid,0,Bid+sl*Point,Bid-+tp*Point,comment,0,0,clrRed);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di continuazione Ribassista: ",Symbol());}
    }//end comparing values
  else res="void";

if(iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)<zz[i]&&
    iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)>=macd[i])
    {
    res="sell";
    ticket=OrderSend(_Symbol,OP_SELL,MM_Size(),Bid,0,Bid+sl*Point,Bid-+tp*Point,comment,0,0,clrRed);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di continuazione Ribassista: ",Symbol());}
    }//end comparing values
  else res="void";

if(Minimozz()==true&&Minimomacd()==true&&Minimostcconfermato()==true)
{
 if((iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>zz[i]&&
    iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)<stochastico[i])||
    (iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>zz[i]&&iStochastic(Symbol(),PERIOD_CURRENT,stochasticoKPeriod,stochasticoDPeriod,stochasticoSlowing,MODE_EMA,0,MODE_MAIN,0)<stochastico[i]&&
    stochastico[i]<stochasticoipercomprato))
    {
    res="sell";
    ticket=OrderSend(_Symbol,OP_SELL,MM_Size(),Bid,0,Bid+sl*Point,Bid-+tp*Point,comment,0,0,clrRed);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di inversone Ribassista: ",Symbol());}
    }//end comparing values
  else res="void";

if(iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>zz[i]&&
    iMACD(Symbol(),PERIOD_CURRENT,macdFastEMA,macdSlowEMA,macdSignalSMA,PRICE_LOW,MODE_MAIN,0)<=macd[i])
    {
    res="sell";
    ticket=OrderSend(_Symbol,OP_SELL,MM_Size(),Bid,0,Bid+sl*Point,Bid-+tp*Point,comment,0,0,clrRed);
    displayAlert=true;
      if(displayAlert==true){
         Alert("Divergenza di inversone Ribassista: ",Symbol());}
     }//end comparing values
      else res="void";
      }
   }
}
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   ChartSetInteger(0,CHART_SHOW_GRID,0,false);
   ChartSetInteger(0,CHART_MODE,0,CHART_CANDLES);
   ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,0,true);
   ChartSetInteger(0,CHART_COLOR_BACKGROUND,clrWhite);
   ChartSetInteger(0,CHART_COLOR_CHART_UP,clrGreen);
   ChartSetInteger(0,CHART_COLOR_CHART_DOWN,clrRed);
   ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,clrGreen);
   ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,clrRed);
   ChartSetInteger(0,CHART_COLOR_FOREGROUND,clrBlack);
 
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
DivergenzaLong();
DivergenzaShort();
   
  }
//+------------------------------------------------------------------+
 
Skull00: hello everyone, I'm getting the array out of range error with my ea ... Can anyone help me out? Thanks in advance
  1. Please post only in English on this forum. Use the automatic translation tool if needed. Use simple language structure when using mechanical translation. 2013.08.09

  2. We have no idea where in that code you get the error.
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  3. Your code.
    if(iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,1)&&
        iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,2)&&
        iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0)>iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,3))
        return(true);
        else 
         return(false);
    Don't copy and paste function calls.
    double Z0=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0);
    double Z1=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,1);
    double Z2=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,2);
    double Z3=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,3);
    if(Z0>Z1&&
        Z0>Z2&&
        Z0>Z3)
        return(true);
        else 
         return(false);
    Simplify
    double Z0=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,0);
    double Z1=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,1);
    double Z2=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,2);
    double Z3=iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",12,5,3,0,3);
    return Z0>Z1&&Z0>Z2&&Z0>Z3;
  4. Your code will not work. you need to find the first and second ZigZag index with a non-EMPTY_VALUE, non-zero values. ZZ uses section. It will not have consecutive values.