DTTB Indicator

The “DoubleTripleTopBottom” (DTTB) indicator has been developed on the basis of the MT4 ZigZag indicator and is capable of identifying the following double- and triple-top/bottom reversal chart patterns:

1) Double Top
2) 1-2-3 Bearish Reversal
3) Triple Top
4) Head & Shoulders
5) Double Bottom
6) 1-2-3 Bullish Reversal
7) Triple Bottom
8) Inverted Head & Shoulders

This indicator can give you plenty of very good signals but also some false signals if trend is too strong and doesn’t allow the market to retrace or reverse. It’s recommended to use this indicator in combination with additional tools for technical analysis, like S&R levels, RSI on a higher time frame, as well as to take into account fundamental data and events.

Indicator parameters

The first 3 parameters are the same as for the original ZigZag indicator (InpDepth, InpDeviation, InpBackstep).

TrendDepth: Sets how deep/steep a trend must be, in proportion to the height of the reversal pattern that may form at the end of it, in order for the reversal pattern and signal to be valid. A higher value would result in the recognition of fewer patterns and the generation of fewer signals while a lower value would result in more patterns and more signals.
Recommended range for this parameter: 1.0 – 4.0 (default: 1.0).

TrendLength: Sets the minimum number of highs that must precede a bearish reversal pattern and must lie below the top of the pattern in order for the pattern and signal to be valid and vise versa. A higher value would result in the recognition of fewer patterns and the generation of fewer signals while a lower value would result in more patterns and more signals.
Set a value between 0 and 14 (default: 2).

BreakNeckLinePIPs: By how many PIPs the neckline (price level of the intermediate low(s) between the highs of a bearish reversal pattern or the intermediate high(s) between the lows of a bullish reversal pattern) must be broken for a signal to be generated.
Use lower values for lower time frames and higher values for higher time frames (default: 5.0).

AlertWindows: Activate / deactivate an alert window that pops up whenever a signal is generated.

DisplayPatternLabels: Set whether the names of the patterns should be displayed above/below the patterns.

BearishPatternColor: Set the color of bearish reversal patterns and buying signal arrows on the chart.BullishPatternColor: Set the color of bullish reversal patterns and selling signal arrows on the chart.

Use in an EA

  • Indicator buffer with index 1 contains the BUY signals (value 0: no signal, value > 0: open price of buy signal).

  • Indicator buffer with index 2 contains the SELL signals (value 0: no signal, value > 0: open price of sell signal).

  • Indicator buffer with index 3 contains the type number of the identified patterns (value -1: no pattern,
    value 0: Double Top,
    value 1: 1-2-3 Bearish Reversal,
    value 2: Triple Top,
    value 3: Head & Shoulders,
    value 4: Double Bottom,
    value 5: 1-2-3 Bullish Reversal,
    value 6: Triple Bottom,
    value 7: Inverted Head & Shoulders).

  • Indicator buffer with index 4 contains the prices of the highest highs of bearish reversal patterns and the lowest lows of bullish reversal patterns which serve as stop loss reference levels when the indicator is used in an EA (SL would normally be set a few PIPs above the highest high or below the lowest low of a reversal pattern).

Use the iCustom() function to make an EA check for buy and sell signals of the DTTB indicator, as in this example code:

// Set parameters:
int InpDepth = 12;
int InpDeviation = 5;
int InpBackstep = 3;
double TrendDepth = 1.0;
double TrendLength = 2;
double BreakNecklinePIPs = 5.0;

// Define pattern and signal variables:
double Pattern;
double Signal = 0.0; // no signal

// Stop Loss:
double SL = 0; // no SL

// Check for pattern and signal:
Pattern = iCustom(NULL, 0, "DoubleTripleTopBottom", InpDepth, InpDeviation, InpBackstep, TrendDepth, TrendLength, BreakNecklinePIPs, 3, 0);

if (Pattern >= 0.0 && Pattern <= 3.0) { // bearish reversal pattern with SELL signal
     // Get open price for SELL order:
     Signal = iCustom(NULL, 0, "DoubleTripleTopBottom", InpDepth, InpDeviation, InpBackstep, TrendDepth, TrendLength, BreakNecklinePIPs, 2, 0);
     // Set SL 2 PIPs above the highest high of the bearish reversal pattern:
     SL = iCustom(NULL, 0, "DoubleTripleTopBottom", InpDepth, InpDeviation, InpBackstep, TrendDepth, TrendLength, BreakNecklinePIPs, 4, 0) + (20 * Point);
}
else if (Pattern >= 4.0) { // bullish reversal pattern with BUY signal
     // Get open price for BUY order:
     Signal = iCustom(NULL, 0, "DoubleTopBottom", InpDepth, InpDeviation, InpBackstep, TrendDepth, TrendLength, BreakNecklinePIPs, 1, 0);
     // Set SL 2 PIPs below the lowest low of the bullish reversal pattern:
     SL = iCustom(NULL, 0, "DoubleTripleTopBottom", InpDepth, InpDeviation, InpBackstep, TrendDepth, TrendLength, BreakNecklinePIPs, 4, 0) - (20 * Point);
}

Position handling and stop policy

It’s recommended to set stop loss a few PIPs above the highest high of the bearish reversal pattern or below the lowest low of the bullish reversal pattern (use indicator buffer 4 as described above).
Set take profit at a distance that is twice or three times the distance of SL (1:2 or 1:3 risk:reward ratio).
Using trailing stop and a partial take profit strategy might improve your results when trading with this indicator.