This code is the MQL5 version of the Zigzag indicator for MetaTrader 4.
Attention! The AlexSTAL_OutsideBar.mqh library should be located in ..\MQL5\Include\ folder of the MetaTrader 5 client terminal.
I think that ZigZag is something like compression of the price chart. The ZigZag can be calculated using the price of the bar (for example, Close price) or High/Low prices of the bar (the most common used method)
While working with the standard ZigZag, proposed by MetaQuotes, I have found some errors. The main problem is that standard ZigZag doesn't proceed the case of the outside bar.
Let's define the features of the "correct" ZigZag implementation:
Let's consider using the example (EURUSD, H1, 2006, December 8-13). Here we have two cases with the outside bar. The typical ZigZag cannot constuct the "correct" picture.
Figure 1. Typical ZigZag with input parameters [12;5;3] and [12;0;0]
Figure 2. Zigzag2 R with input parameters [12;5;3]
Figure 3. Zigzag2 R with input parameters [12;0;0]
At first glance, the correct construction is presented at Figure 3 but here are some features:
The ZigZag segments must be constucted this way.
I have tested many cases of the following ZigZag algorithms: ZigZag MT3, ZigZag, Zigzag R, Zigzag2 R, ZigZag_NK, ZigZag_ZUP89_nen, ZigZag_new_nen4, CZigZag, Swing_ZZ_1, DT_ZZ_nen, ZigZag_Talex, Reverse_ZZ, Points_ZZ_1, i_MF_Fractal_ZZ_3in1, ang_Amp_ZZ, ZigzagFr_v1, NonLagZigZag_v2, ZZ_FF_v3, ZigZag Ensign, ZigZag tauber, SQZZ Товаровед, ZZ_2L_nen wellx, Channel ZZ, Azzx_larryzz_3_0, RPoint, RPoint-m v2, ZigZagTF. But none of them has solved the problem correctly.
Here are the figures with this indicator:
Figure 4. Professional ZigZag with input parameters [12;0]
Figure 5. Professional ZigZag with input parameters [23;0]
Figure 6. EURUSD, H1, November 29-December 7. (Red line: ZigZag with input parameters [7;0;0]. Blue line: Zigzag2 R with input parameters [7;0;0].)
Figure 7. EURUSD, H1, 2010, November 29 - December 7. The correct construction of ZigZag segments.
Unfortunately this version is not perfect, but I am working on it.
Because of the channel algorithm (iHighest/iLowest), sometimes it skips the highs.
Please inform me about the bugs and features of this indicator.
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/263
The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.Average Directional Movement Index (ADX)
The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.