How to get several Zigzag highs and lows form UNIVERSAL ZIGZAG?

 

As you know UNIVERSAL ZIGZAG is a complete Zigzag expert and indicator. We can call it as below in our expert:

int handle=iCustom(Symbol(),Period(),"iUniZigZagSW",SrcSelect,
               DirSelect,
               RSIPeriod,
               RSIPrice,
               MAPeriod,
               MAShift,
               MAMethod,
               MAPrice,
               CCIPeriod,
               CCIPrice,
               ZZPeriod);

And by these couple of lines of code we can get the last high an low of zigzag:

double lhb[], zz[];
if(CopyBuffer(handle,4,0,**1**,lhb)<=0)
     {
      Print("Error obtaining data from the ZigZag 2");
      return;
     }
   // index of the bar when counting to the right of zero
   ind=bars-(int)lhb[0]-1;

   // value of the ZigZag at the ind bar
   if(CopyBuffer(handle,2,ind,**1**,zz)<=0)
     {
      Print("Error obtaining data from the ZigZag 3");
      return;
     }
     ...

As I have bold the 1 number, those are count of highs that we want to know.

The question is, how can I get last 3 or more highs or lows of Zigzag?

Even if increase the count of array in the  CopyBuffer(handle,4,0,**1**,lhb)  the result wont be correct.

The  CopyBuffer(handle,2,ind,1..X,zz)  returns incorrect number or just the last high or low of Zigzag.

Universal ZigZag
Universal ZigZag
  • www.mql5.com
ZigZag is one of the most popular indicators among the MetaTrader 5 users. The article analyzes the possibilities for creating various versions of the ZigZag. The result is a universal indicator with ample opportunities to extend its functionality, which is useful in the development of trading experts and other indicators.