MetaTrader5
Mastering DoubleZigZag: Your Go-To EA for MetaTrader 5
Meet the Minds Behind DoubleZigZag: The innovative concept comes from Maksim, while the coding wizardry was crafted by barabashkakvn.
This Expert Advisor employs two ZigZag indicators for thorough market analysis. It utilizes a smaller ZigZag with the settings of (13.5,3) alongside a larger ZigZag, with parameters scaled up by eight: (13*8,5*8,3*8).
//--- Create handle for the iCustom indicator
handle_iCustom=iCustom(Symbol(),Period(),"Examples\\ZigZag",13,5,3);
//--- Check if the handle was successfully created
if(handle_iCustom==INVALID_HANDLE)
{
//--- Report failure and display error code
PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d",
Symbol(),
EnumToString(Period()),
GetLastError());
//--- Abort if the indicator failed
return(INIT_FAILED);
}
//--- Create handle for the scaled iCustom indicator
handle_iCustomX8=iCustom(Symbol(),Period(),"Examples\\ZigZag",13*8,5*8,3*8);
//--- Check if the handle was successfully created
if(handle_iCustomX8==INVALID_HANDLE)
{
//--- Report failure and display error code
PrintFormat("Failed to create handle of the iCustomX8 indicator for the symbol %s/%s, error code %d",
Symbol(),
EnumToString(Period()),
GetLastError());
//--- Abort if the indicator failed
return(INIT_FAILED);
}
When it comes to making trading decisions, we analyze the two legs of the last peak from the larger ZigZag (13*8,5*8,3*8) and count how many peaks from the smaller ZigZag (13,5,3) fit within those legs.
If a signal to open a BUY position comes in, all existing SELL positions are closed, and vice versa. If a signal to open a SELL position is triggered, all BUY positions are closed.
Parameters of the Expert Advisor:
k: The ratio of the number of peaks from the smaller ZigZag occurring within the legs of the larger ZigZag.
k2: The ratio of the price difference at the peaks of the larger ZigZag.
Example:
In the chart above, the larger ZigZag (13*8,5*8,3*8) is marked in red, while the smaller ZigZag (13,5,3) is shown in yellow.
Here, the peaks of the larger ZigZag are labeled as ABC.
The legs AB and AC contain nine peaks from the smaller ZigZag (13,5,3).
Testing Results on EURUSD, M1:
2017.08.10