OPEN-SOURCE SCRIPT

Three Drive Pattern Detector [LuxAlgo]

By LuxAlgo
Wizard
The Three Drives Pattern Detector indicator focuses on detecting and displaying completed Three Drives patterns on the user chart. This harmonic pattern is characterized by successive higher highs / lower lows following specific ratios.

The script uses a multi-length swing detection approach, as well as adjusting ratios to ensure flexibility and a maximum number of visible Three Drives patterns.

🔶 USAGE

snapshot

The bullish/bearish Three Drives pattern is commonly interpreted as a reversal pattern and is characterized by three extensions (drives) and two intermediary retracements creating consecutive higher lows (for a bullish case) or lower highs (for a bearish case).

snapshot

The multi-length swing detection approach taken by the indicator allows for detecting shorter-term alongside medium/longer-term patterns simultaneously, allowing to increase in the amount of detected patterns.

snapshot

Users can set a Minimum Swing length (for example 2) and a Maximum Swing length (for example 100) which defines the range of the swing point detection length, higher values for these settings will detect longer-term Three-Drives patterns, while a larger range will allow for the detection of a larger number of patterns.

snapshot

Sometimes multiple dashed lines as the last segment can be observed. This means multiple Three Drives patterns sharing multiple swing points have formed, with only the last segment being different.

🔹 Retracement/Extension Ratios

snapshot

The Three Drives pattern often associates the retracement/extension to Fibonacci ratios of respectively 0.618/1.272.

Some sources specify a maximum retracement/extension level of 0.786/1.618, which means the retracement should be within the 0.618-0.786 range and the extension between 1.272-1.618.

Since finding a pattern where the retracement/extension is precisely at the 0.618/1.272 levels, or even between 0.618-0.786/1.272-1.618 is rare, the script allows users to adjust those ratios, which ensures more flexibility. Depending on the widening/tightening of the ratios, allowing users to find more patterns (but potentially less valid) or more valid (but fewer patterns).

snapshot

In the example above, "Show Ratios" is set to "Ratios With Margin", showing the ideal retracement/extension level together with the margin, while in the example below, "Show Ratios" is set to "Ratios", which shows only a line where the price should ideally reverse.

snapshot

While setting the ratios wider will result in more frequent but less valid patterns, it can also create good trading opportunities.

snapshot

🔹 Best Practices

The indicator doesn't include Stop Loss (SL) or Take Profit (TP) levels, however, the 1.618 Fibonacci Extension level of the last leg can commonly be used as stop loss.

Typical Take Profit areas include:

  • Starting point of the pattern
  • Each retracement level (2x)
  • The 0.618 retracement level of the complete pattern


snapshot

In the above bullish examples, the price was lower than the lowest point of the pattern. The price reversed and attained all TP levels without hitting the SL level.

snapshot

In the above bearish example, the price went above the highest point of the pattern but did not hit the SL level, after which two TP levels were hit. Then, the price quickly went up, just missing the SL level before it came back down again, hitting the last 2 TP levels.

snapshot

This example shows that other Fibonacci levels an also be effective when combined with the Three Drives pattern, even in the longer term.

🔶 DETAILS

🔹 Multi Length

The core of this publication is the multi-length swing detection. To ensure the maximum amount of Three Drives patterns are found, up to 99 different swing length periods can be used to detect swing points which are then tested for valid patterns.

snapshot

Using a wider variety of swing points also ensures that patterns visible only with specific Swing settings can be found on the same chart without the user needing to constantly adjust the Swing settings to find other patterns.

The user only needs to set the desired minimum and maximum Swing Length.

snapshot

In this case, swing detection using swing Lengths from 3 to 100 (97 different) are computed and evaluated for patterns. Three different patterns were found on the same chart, with swing lengths 3, 4, and 6.

Note: The Maximum Swing length should be equal to or higher than the Minimum Swing Length. If the maximum value is lower than the minimum, the script will automatically take the minimum value as the maximum to prevent errors.

🔹 Width Margin %

snapshot

Users can filter out patterns based on the duration of each extension/retracement segment. When the users want segments of the detected patterns to be of a similar duration, the width percentage should be set lower. When the focus is on detecting more patterns the width percentage can be set higher.

🔹 Retracement/Extension Settings

snapshot

  • Show Ratios, set to Ratios, show the ideal Fibonacci retracement/extension level, while Ratios With Margin (example below) show the additional margins for retracement/extension.
  • The upper and lower limits can be visualized while hovering over the calculated ratio label.
  • The dashed line shows an older pattern, where the last leg has been updated.


snapshot

🔹 Last Known Pattern

snapshot

The included dashboard highlights the date of the most recently detected pattern; the text will show "None" if no pattern is found.

🔹 Calculated Bars

The "Calculated Bars" setting makes use of the recently introduced calc_bars_count parameter, making it possible to effectively reduce the number of historical bars during the computation of the script, which significantly improves the loading speed of the script.

Users wishing to see the most recent patterns can set this setting to 1000 for example, where only the most recent 1000 bars are used to find patterns. If every bar must be used for pattern detection, set "Calculated bars" at 0.

🔶 SETTINGS

  • Minimum Swing Length: Minimum length used for the swing detection.
  • Maximum Swing Length: Maximum length used for the swing detection.
  • Retracement: Range of required ratios used for testing retracements.
  • Extension: Range of required ratios used for testing extensions.
  • Width Margin: Influences the symmetry of the pattern; with a higher number allowing for less symmetry.


🔹 Style

  • Text Size: Text size of the ratio labels.
  • Show Ratios: Show the ideal ratio, upper/lower limit of ratios, or none.


🔹 Dashboard

  • Show Dashboard: Toggle dashboard which shows the date of the last found pattern.
  • Location: Location of the dashboard on the chart.
  • Size: Text size.


🔹 Calculation

  • Calculated Bars: Allows the usage of fewer bars for performance/speed improvement.
Chart patternsfibonnacciHarmonic PatternsluxalgopatternThree DrivesTrend Analysis
LuxAlgo
Wizard
Get access to our exclusive tools: luxalgo.com

Join our 150k+ community: discord.gg/lux

All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer