icustom ZigZag - page 4

 

Hello all,

I've been looking for an answer aswell of how to get those high and low values from the ZigZag indicator. As i didn't come up with a solution, i've programed it myself,  and i'm sharing it so other people that find same problem have already a solution.

First problem is that ZigZag indicator redraws, so, getting last high or low, needs a little bit of a trick.

To get other values we should add this code to your EA.

 Please notice that the cycle begins with i=2, 10000 is the number of highs or lows you need, 10.000 is just an example.

The values will be saved on Array temp in wich

Position 0 saves the last high or low drawn in the chart, position 1 saves the high or low previous and so on... 

for(int i=2;i<10000;i++)

       {

         zo=iCustom(Symbol(),PERIOD_M15,"ZigZag",0,i);

         if(zo!=0) // while Zigzag does't get a higher high, or deapth, deviation , etc conditions are not yet satisfied, ZigZag indicator equals zero , so we need to filter this empty values.

            {

                temp[k]=zo; // highs and lows are saved in array temp[]

                k++; 

      } 

 

 

 Now, to get last Wave value, you just have use current price, you comparing it to value saved in position 0,  

 if (Ask>temp[0]) means that last value was a low, so to get distance you just need to do last_wave=Ask-temp[0]

else means last value was a high to get distance do last_wave= temp[0]-Ask

if you don't need to know wheather it's a low or a high, and you just want the distance, then you just do last_wave= MathAbs(Ask-temp[0]) (distance always positive, right? ;) )

and that's about it, hope it helped.

good luck in your programming! 

 
Sigur:

Hello all,

I've been looking for an answer aswell of how to get those high and low values from the ZigZag indicator. As i didn't come up with a solution, i've programed it myself,  and i'm sharing it so other people that find same problem have already a solution.

First problem is that ZigZag indicator redraws, so, getting last high or low, needs a little bit of a trick.

To get other values we should add this code to your EA.

 Please notice that the cycle begins with i=2, 10000 is the number of highs or lows you need, 10.000 is just an example.

The values will be saved on Array temp in wich

Position 0 saves the last high or low drawn in the chart, position 1 saves the high or low previous and so on... 

<CODE DELETED>

Please read some other posts before posting . . .

Please   edit   your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 

 
RaptorUK:

Please read some other posts before posting . . .

Please   edit   your post . . .    please use the   SRC   button to post code: How to use the   SRC   button. 



Dear Raptor,

I did read the other posts, although it provided a solution, it was just the best for me as we are creating objects and deleting them where in my opinion and has the code shared shows, there is no need.

But if you don't find my post useful, you can always delete it, you are a moderator right? ;) 

 
Sigur:


Dear Raptor,

I did read the other posts, although it provided a solution, it was just the best for me as we are creating objects and deleting them where in my opinion and has the code shared shows, there is no need.

So you read other posts yet you still posted code in plain text, why ?  did you follow the link I posted ?  How to use the   SRC   button.    do you understand why I asked you to edit your post ?
 
Sigur:


Dear Raptor,

I did read the other posts, although it provided a solution, it was just the best for me as we are creating objects and deleting them where in my opinion and has the code shared shows, there is no need.

But if you don't find my post useful, you can always delete it, you are a moderator right? ;) 


See  https://www.mql5.com/en/code/10920

same as ZigZag

first buffer normal ZigZag

with last two buffers you have the highs and lows

 
Thank you Raptor, missed that post indeed, it even makes it easier!
 
Sigur:
Thank you Raptor, missed that post indeed, it even makes it easier!
And yet you still haven't edited your post . . . 
 
Hallo , im trying to use the zig zag indicator as you did . Do i have to define this indicator somehow before i use it ? It is allready in mql4 like rsi and more?
 
qjol:

Hi gjol,


please advice me how to get stochatic value from the zigzag price p0,p1,p2,p3,p4,p5 ?


int n, i, 
   double p0, p1, p2, p3, p4, p5;
   i=0;
      while(n<5)
      {
      if(p0>0) {p5=p4; p4=p3; p3=p2; p2=p1; p1=p0; }
      p0=iCustom(Symbol(),0,"zigzag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
      if(p0>0) {n+=1; }
      i++;
      }
 
Abdelrahman Abdelgaied Mahmoud:

what if i want to know the last three values ?

Then read on for the next two values.