A ZigZag indicator with non-repainting price reversals suitable for automation
The ZigZag indicator provided by MetaQuotes is of little use. The algorithm is flawed and the implementation performes badly. Furthermore the indicator repaints past ZigZag reversals and can't be used for automation.
This indicator fixes those issues. The display can be changed from ZigZag lines to reversal points (aka semaphores). Once the ZigZag direction changed the semaphore will not change anymore. Like the MetaQuotes version the indicator uses a Donchian channel for determining legs and reversals but this indicator draws vertical line segments if a large bar crosses both upper and lower Donchian channel band. Additionally it can display the trail of a ZigZag leg as it developes over time and supports manual period stepping via hotkey (parameter change via keyboard). Finally the indicator supports signaling of new ZigZag reversals.
Installation
The indicator setup consists of multiple files. All files are required for the indicator to work.
Unpack the attached ZIP file somewhere. Then open your terminal's data folder by clicking "Main menu" -> "File" -> "Open Data Folder".
The content of "<zip-file>/mql4/indicators/" goes into "<data-folder>/mql4/indicators/".
The content of "<zip-file>/mql4/libraries/" goes into "<data-folder>/mql4/libraries/".
The content of "<zip-file>/mql4/scripts/" goes into "<data-folder>/mql4/scripts/".
The content of "<zip-file>/sounds/" goes into "<data-folder>/sounds/".
Restart your terminal. Go to "Main menu" -> "Tools" -> "Options". Click on the tab "Expert Advisers" and check the option "Allow DLL imports". Now you can load the indicator in the usual way.
All files are open source. The indicator sources can be found here: https://github.com/rosasurfer/mt4-mq...ors/ZigZag.mq4
The DLL sources can be found here: https://github.com/rosasurfer/mt4-expander
As the name of the indicator conflicts with the built-in MetaQuotes indicator you may rename it to whatever you like (rsf is short for the Github project of "rosasurfer").
Inputs parameters (from the source documentation)
• ZigZag.Periods: Lookback periods of the Donchian channel.
• ZigZag.Periods.Step: Controls parameter 'ZigZag.Periods' via the keyboard. If non-zero it enables the parameter stepper and defines its step size. If zero the parameter stepper is disabled.
• ZigZag.Type: Whether to display ZigZag lines or ZigZag semaphores. Can be shortened as long as distinct.
• ZigZag.Width: Controls the ZigZag's line width/semaphore size.
• ZigZag.Semaphores.Wingdings: Controls the WingDing symbol used for ZigZag semaphores.
• ZigZag.Color: Controls the color of ZigZag lines/semaphores.
• Donchian.ShowChannel: Whether to display the Donchian channel used by the internal calculation.
• Donchian.ShowCrossings: Controls the displayed Donchian channel crossings.
"Off": No crossings are displayed.
"First": Only the first crossing per direction is displayed (the moment when the ZigZag creates a new leg).
"All": All crossings are displayed. Displays the trail of the ZigZag leg as it developes over time.
• Donchian.Crossings.Width: Controls the size of the displayed Donchian channel crossings.
• Donchian.Crossings.Wingdings: Controls the WingDing symbol used for Donchian channel crossings.
• Donchian.Upper.Color: Controls the color of upper Donchian channel band and crossings.
• Donchian.Lower.Color: Controls the color of lower Donchian channel band and crossings.
• Max.Bars: Maximum number of bars back to calculate the indicator (performance).
• Signal.onReversal: Whether to signal ZigZag reversals (the moment when the ZigZag creates a new leg).
• Signal.onReversal.Sound: Whether to signal ZigZag reversals by sound.
• Signal.onReversal.SoundUp: Sound file used for signaling ZigZag reversals to the upside.
• Signal.onReversal.SoundDown: Sound file used for signaling ZigZag reversals to the downside.
• Signal.onReversal.Popup: Whether to signal ZigZag reversals by a popup (MetaTrader alert dialog).
• Signal.onReversal.Mail: Whether to signal ZigZag reversals by e-mail.
• Signal.onReversal.SMS: Whether to signal ZigZag reversals by text message.
• Sound.onCrossing: Whether to signal all Donchian channel crossings (widening of the channel).
• Sound.onCrossing.Up: Sound file used for signaling a Donchian channel widening to the upside.
• Sound.onCrossing.Down: Sound file used for signaling a Donchian channel widening to the downside.
• AutoConfiguration: If enabled all input parameters can be overwritten with custom default values (via framework config).
Chart legend
In the chart legend the indicator shows the period configuration, the length of the known ZigZag trend, the number of bars with a still unknown trend, the channel level to cross for creating a new ZigZag reversal, and the active signaling options.
If in the below picture price advances further and crosses the upper Donchian channel the 4 bars of an "unknown" trend will become a new uptrend of length "4" (a ZigZag reversal occurred). If price turns around and crosses the lower channel band the 4 bars of an "unknown" trend will be added to the existing "known" trend (5 bars), and the overall "known" trend will become 9.
The sign "+" or "-" in front of the known trend shows the direction of the current ZigZag trend.
Signaling via email and/or text message
These are advanced signaling options which I use to be independant of the MetaQuotes ecosystem. They require a special setup and for text messages a payed subscription with a telco service provider. I use it only on the server and have a subscription with Clickatell, so I'll skip it for the moment.
In the following post I'm going to explain parameter navigation via keyboard. This allows the user to explore the parameter space of the ZigZag similar to the optimizer in tester.
Attached File(s)
ZigZag.zip
1.7 MB
|
1,224 downloads
6