Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Professional ZigZag - MetaTrader 5 Script | Trading Script Download - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

Professional ZigZag - indicator for MetaTrader 5

Professional ZigZag - indicator for MetaTrader 5

Professional ZigZag - indicator for MetaTrader 5

Professional ZigZag - indicator for MetaTrader 5

Professional ZigZag - indicator for MetaTrader 5

Professional ZigZag - indicator for MetaTrader 5

Professional ZigZag - indicator for MetaTrader 5

Professional ZigZag - indicator for MetaTrader 5

attention! This version of the ZigZag indicator is based on the ZigZag code and is published here, PC, with the permission of the author. I've tested this version and fixed the bugs in the algorithm.

This code is the MQL5 version of the ZigZag indicator for MetaTrader 4.

attention! AlexSTAL_OutsideBar.mqh library should be located in the ..\MQL5\Include \ folder of the MetaTrader 5 client terminal.

I think of a zigzag as similar to a compression on a price chart. ZigZag can be calculated using the price of the bar (for example, the closing price) or the high/low price of the bar (the most common method)

I found some bugs while using the standard ZigZag proposed by MetaQuotes. The main problem is that standard ZigZag does not handle the case of external columns.

In 2007 Rashid Umarov (Rosh) had published code for Zigzag2 R with external bar processing (DRAW_ZIGZAG style instead of DRAW_SECTION).

Let's define the characteristics of a "correct" ZigZag implementation:

Let's consider a usage example (EURUSD, first half, 2006, 8-13 December). Here we have two cases with external bars. The typical zigzag does not create the “right” picture.

Professional ZigZag - indicator for MetaTrader 5

Figure 1. Typical zigzag input parameters are [12;5;3] and [12;0;0]

Professional ZigZag - indicator for MetaTrader 5

Number 2. Zigzag2 R input parameters[12;5;3]


Professional ZigZag - indicator for MetaTrader 5

Figure 3. Zigzag2 R input parameters are [12;0;0]

At first glance, the correct structure is located in Figure 3 but here are some features:

Professional ZigZag - indicator for MetaTrader 5

ZigZag segments must be constructed this way.

I tested various scenarios 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, channelZZ, Azzx_larryzz_3_0, RPoint, RPoint-m v2, ZigZagTF. But none of them solved the problem correctly.

Here is the data for this indicator:

Professional ZigZag - indicator for MetaTrader 5

Figure 4. Professional ZigZag with input parameters [12;0]

Professional ZigZag - indicator for MetaTrader 5

Figure 5. Professional ZigZag [23;0] with input parameters

Some features of this version:

Professional ZigZag - indicator for MetaTrader 5

Figure 6. EURUSD, first half of the year, November 29 to December 7. (Red line: Zigzag line, input parameter is [7;0;0]. Blue line: Zigzag2 R input parameter is [7;0;0].)

Professional ZigZag - indicator for MetaTrader 5

Figure 7. EURUSD, first half of 2010, November 29 to December 7. Correct construction of the zigzag correction wave segment.

Unfortunately this version isn't perfect, but I'm working on it.

Due to the channel algorithm (iHighest/iLowest), sometimes it skips the high points.

Please inform me about the bugs and functionality of this indicator.


Attachment download

📎alexstal_outsidebar.mqh (10.9 KB)

📎alexstal_zigzagprof.mq5 (17.29 KB)

Source: MQL5 #263

Verification code Refresh