You only have to read the buffer(s) until you hit a value this value will be the previous pivot point.
Combine that with the current close and you have the last leg of ZigZag.
-
Don't try to 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 EA/indicator (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 #33 2017.05.23 - EAs : Don't do per tick that you can do per bar, or on open.
If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts and you recalculate.)
If you are waiting for an order to open or close, only look when OrdersTotal (or MT5 equivalent) has changed.
How to get backtesting faster ? - MT4 - MQL4 programming forum - Indicators: Code it properly so it only recomputes bar zero (after the initial run.)
How to do your lookbacks correctly.
Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)
- EAs : Don't do per tick that you can do per bar, or on open.
-
Don't try to 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 EA/indicator (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 #33 2017.05.23 - EAs : Don't do per tick that you can do per bar, or on open.
If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts and you recalculate.)
If you are waiting for an order to open or close, only look when OrdersTotal (or MT5 equivalent) has changed.
How to get backtesting faster ? - MT4 - MQL4 programming forum - Indicators: Code it properly so it only recomputes bar zero (after the initial run.)
How to do your lookbacks correctly.
Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)
- EAs : Don't do per tick that you can do per bar, or on open.
ok thanks that makes more sense. i will investigate these options.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
My EA has used the icustom function to bring in the ZigZag values that i need. However the optimization testing takes forever. In an attempt to speed the optimisation up, I believe the EA may work quicker if I integrate the Zigzag indicator into my EA directly. (I hope that is accurate)
to that end i have been following this article to see if I could achieve this -= https://www.mql5.com/en/articles/1456
I seem to have gotten a little lost in getting the arrays to work correctly.
I have the following code in int start()
any help much appreciated