Coding Zig Zag

To add comments, please log in or register
Big Guy
28
Big Guy  

I want to code Zig Zag into an EA.

The Zig Zag custom indicator that i imported into the EA Builder program comes with three Buffers.  Hi, Low and Zig Zag buffers.   But on the chart , the data window only shows the one Zig Zag buffer and it only has a value at the points where the line is drawn to. 

How do i know the values and positions of all three buffers?  What are these three buffers, or is there only one? 

How would I program buy when Zig Zag makes an up line and vice versa....

Thanks.

Seng Joo Thio
750
Seng Joo Thio  
Big Guy:

I want to code Zig Zag into an EA.

The Zig Zag custom indicator that i imported into the EA Builder program comes with three Buffers.  Hi, Low and Zig Zag buffers.   But on the chart , the data window only shows the one Zig Zag buffer and it only has a value at the points where the line is drawn to. 

How do i know the values and positions of all three buffers?  What are these three buffers, or is there only one? 

How would I program buy when Zig Zag makes an up line and vice versa....

Thanks.

The Zig Zag indicator draws only 1 line, which is based on the values in buffer 0. Buffer 1 contains all the Highs, and buffer 2 contains all lows. In general, accessing buffer 0 is enough to get both highs and lows.

You use iCustom() to get the handle of Zig Zag in OnInit(), then use CopyBuffer() in OnTick() to get the actual values for your computation.

When previous bar (i.e. bar 2 or 1) value is zero, followed by a high (i.e. value higher than or equal to close price) in the next bar (i.e. bar 1 or 0), you have your first indication that it will make an up line. Same goes for a down line.

Enjoy your coding, and we're all here to help further, when you hit a snag.

William Roeder
19170
William Roeder  
Big Guy: I want to code Zig Zag into an EA.
Don't try do that. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)
Just get the value(s) of the indicator(s) into the EA (using iCustom) and do what you want with it.
You should encapsulate your iCustom calls to make your code self-documenting.
          Detailed explanation of iCustom - MQL4 programming forum
To add comments, please log in or register