Get Last FIXED values of ZigZag indicator in my EA

 

i'd like to access the last three fixed values of ZigZag Highs indicator (standard one) 

i have seen other threads discussing the same problem but they are all in mql4 and i use mql5 


Here's my code ,but no matter i change the indices , it only produces the last non fixed value of the High !


     double zzl[]; // array to store values 
     
     
     ArraySetAsSeries(zzl,true);
     
     
     
     int zz_handle = iCustom(_Symbol,_Period,"Examples//ZigZag");
     
     
     CopyBuffer(zz_handle,1,0,20,zzl);  // buffer for the high zigzag

     
     if (zzl[3] != 0)   // i have tried different indices but they all produce same values 
     
     Alert(zzl[3]);
 
your buffer index correspond to Bar index.

in the indicator zigzag, not all index have valid value.most of the buffer index are EMPTY_VALUE.

you have to check it with a for circle. pick out the first 3 non-empty-values' index in sequence.
 

Perhaps you should read the manual, especially the examples. They all (including iCustom) return a handle (an int.) You get that in OnInit. In OnTick (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.03.08
          How to call indicators in MQL5 - MQL5 Articles 12 March 2010

 
//Before the main function
double ZigZagArray[],zigzag[100];
int ZigZagHandle;

void onTick(){
//Calling the function
CheckForZigZag();
//Print as many as you want. for example 2 value here
Print(zigzag[0],zigzag[1]);
}
void CheckForZigZag()
  {
   ZigZagHandle=iCustom(_Symbol,PERIOD_M15,"Examples\\ZigZag",12,5,3);
   ArraySetAsSeries(ZigZagArray,true);
   CopyBuffer(ZigZagHandle,0,0,100,ZigZagArray);
   int zigzag_counter=0;
   for(int i=0; i<100; i++)
     {
      if(ZigZagArray[i]!=0.0)
        {
         zigzag[zigzag_counter]=ZigZagArray[i];
         zigzag_counter++;
        }
     }
  }
 
Mohsen Sojoudi #:
   ZigZagHandle=iCustom(_Symbol,PERIOD_M15,"Examples\\ZigZag",12,5,3);
   ArraySetAsSeries(ZigZagArray,true);
   CopyBuffer(ZigZagHandle,0,0,100,ZigZagArray);

What part of #2 was unclear to you?