how we get price of last zigzag

 

even i use iCustom i cant get price of last zigzag

can some one help plz 

void OnTick()
  {

  double arr[5] = {0,0,0,0,0 };

   for(int j = 0 ; j< 1000 ; j++)
     {
 
      double zigZag =  iCustom(Symbol(),0,"ZigZag",12,5,3,0,j);

      if(zigZag !=EMPTY_VALUE && zigZag !=0)
        {

         if(arr[0]==0)
           {
            arr[0] =zigZag ;
           }

         else
            if(arr[1]==0)
              {
               arr[1]= zigZag;
              }
            else
               if(arr[2] ==0)
                 {
                  arr[2] =zigZag;
                 }
               else
                  if(arr[3] ==0)
                    {
                     arr[3] =zigZag;
                    }
                  else
                     if(arr[4] ==0)
                       {
                        arr[4] =zigZag;

                        break;
            
                       }
                                       
        }
        
     }
     
 
double zig1 = SetIndexBuffer(1,arr  );


 Comment ( zig1   );// get price of last array 
       

}
 
alkosovi14:

even i use iCustom i cant get price of last zigzag

can some one help plz 

i found many code but all use 
CopyBuffer

and CopyBuffer does not existe in mql4 

 

realy thanks bro for u help but a both  codes does not work

the first code block my EA and the second code have error

 
alkosovi14 #: the first code block my EA and the second code have error

So fix it. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
          Code debugging - Developing programs - MetaEditor Help
          Error Handling and Logging in MQL5 - MQL5 Articles (2015)
          Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
          Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

 

When you say the price, do you mean the latest extension or the end of the last leg?

If you mean the values for each leg extension, I don't think its possible except by saving them when they occur in real time....

This code gives  the last extension bar and direction from which you could get the prices.

string txt="";
 double dir=-1;
 string sym=_Symbol;
 int period=_Period;
custom="zigzag";

  for(int x=1;x<500;x++){
   if(iCustom(sym,period,custom,0,x)==0)continue;
   if(iCustom(sym,period,custom,1,x)==0)
     dir=0;else dir=1;
    txt=StringConcatenate(txt,"bar ",x," ",iTime(sym,period,x)," dir ",dir,"\n");
 } 
 
Comment(txt);


 
andrew4789 #:
   if(iCustom(sym,period,custom,0,x)==0)continue;
   if(iCustom(sym,period,custom,1,x)==0)

ZigZag only has one buffer. The second call is bogus.
          How to get time or shift of zigzag top (or bottom) - Symbols - Expert Advisors and Automated Trading - MQL5 programming forum #5 (2021)