OPEN-SOURCE SCRIPT
Trendlines with Breaks Oscillator [LuxAlgo]

The Trendlines with Breaks Oscillator is an oscillator based on the Trendlines with Breaks indicator, and tracks the maximum distance on price from bullish and bearish trendline breakouts.
The oscillator features divergences and trendline breakout detection.
🔶 USAGE

This tool is based on our Trendlines with Breaks indicator, which detects bullish and bearish trendlines and highlights the breaks on the chart. Now, we bring you this tool as an oscillator.
The oscillator calculates the maximum distance between the price and the break of each trendline, for both bullish and bearish cases, then calculates the delta between both.
When the oscillator is above 0, the market is in an uptrend; when it is below 0, it is in a downtrend. An ascending slope indicates positive momentum, and a descending slope indicates negative momentum.
Trendline breaks are displayed as green and red dots on the oscillator. A green dot corresponds to a bullish break of a descending trendline, and a red dot corresponds to a bearish break of an ascending trendline.

The oscillator calculation depends on two parameters from the settings panel: short and long alpha length. These parameters are used to calculate a synthetic EMA with a variable alpha for both bullish and bearish breaks. The final result is the difference between the two averages.
As shown in the image, using the same trend detection parameters but different alphas can produce very different results. The larger the alphas, the smoother the oscillator becomes, detecting bigger trends but making it less reactive.

This tool features the same trendline detection system as the Trendlines with Breaks indicator, which is based on three main parameters: swing length, slope, and calculation method.
As we can see in the image above, the data collected for the oscillator calculation will be different when using different parameters. A larger length detects larger trends. A larger slope or a different calculation method also impacts the final result.
🔹 Signal Line

The signal line is a smoothed version of the oscillator; traders can choose the smoothing method and length used from the settings panel.
In the image, the signal line crossings are displayed as vertical lines. As we can see, the market usually corrects downward after a bearish crossing and corrects upward after a bullish crossing.

Traders can choose among 10 different smoothing methods for the signal line. In the image, we can see how different methods and lengths give different outputs.
🔹 Divergences

The tool features a divergence detector that helps traders understand the strength behind price movements. Traders can adjust the detection length from the settings panel.
As shown in the image, a bearish divergence occurs when the price prints higher highs, but the momentum on the histogram prints lower highs. A bullish divergence occurs when the price prints lower lows, but the histogram prints higher lows.

By adjusting the length of the divergence detector, traders can filter out smaller divergences, allowing the tool to only detect more significant ones.
The image above depicts divergences detected with different lengths; the larger the length, the bigger the divergences are detected.
🔶 SETTINGS
🔹 Trendlines
🔹 Oscillator
🔹 Style
The oscillator features divergences and trendline breakout detection.
🔶 USAGE
This tool is based on our Trendlines with Breaks indicator, which detects bullish and bearish trendlines and highlights the breaks on the chart. Now, we bring you this tool as an oscillator.
The oscillator calculates the maximum distance between the price and the break of each trendline, for both bullish and bearish cases, then calculates the delta between both.
When the oscillator is above 0, the market is in an uptrend; when it is below 0, it is in a downtrend. An ascending slope indicates positive momentum, and a descending slope indicates negative momentum.
Trendline breaks are displayed as green and red dots on the oscillator. A green dot corresponds to a bullish break of a descending trendline, and a red dot corresponds to a bearish break of an ascending trendline.
The oscillator calculation depends on two parameters from the settings panel: short and long alpha length. These parameters are used to calculate a synthetic EMA with a variable alpha for both bullish and bearish breaks. The final result is the difference between the two averages.
As shown in the image, using the same trend detection parameters but different alphas can produce very different results. The larger the alphas, the smoother the oscillator becomes, detecting bigger trends but making it less reactive.
This tool features the same trendline detection system as the Trendlines with Breaks indicator, which is based on three main parameters: swing length, slope, and calculation method.
As we can see in the image above, the data collected for the oscillator calculation will be different when using different parameters. A larger length detects larger trends. A larger slope or a different calculation method also impacts the final result.
🔹 Signal Line
The signal line is a smoothed version of the oscillator; traders can choose the smoothing method and length used from the settings panel.
In the image, the signal line crossings are displayed as vertical lines. As we can see, the market usually corrects downward after a bearish crossing and corrects upward after a bullish crossing.
Traders can choose among 10 different smoothing methods for the signal line. In the image, we can see how different methods and lengths give different outputs.
🔹 Divergences
The tool features a divergence detector that helps traders understand the strength behind price movements. Traders can adjust the detection length from the settings panel.
As shown in the image, a bearish divergence occurs when the price prints higher highs, but the momentum on the histogram prints lower highs. A bullish divergence occurs when the price prints lower lows, but the histogram prints higher lows.
By adjusting the length of the divergence detector, traders can filter out smaller divergences, allowing the tool to only detect more significant ones.
The image above depicts divergences detected with different lengths; the larger the length, the bigger the divergences are detected.
🔶 SETTINGS
🔹 Trendlines
- Swing Detection Lookback: The size of the market structure used for trendline detection.
- Slope: Slope steepness, a value of 0 gives horizontal levels, values larger than 1 give a steeper slope
- Slope Calculation Method: Choose how the slope is calculated
🔹 Oscillator
- Short Alpha Length: Synthetic EMA short period
- Long Alpha Length: Synthetic EMA long period
- Smoothing Signal: Choose the smoothing method and period
- Divergences: Enable or disable divergences and select the detection length.
🔹 Style
- Bullish: Select bullish color.
- Bearish: Select bearish color.
Script de código aberto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Get exclusive indicators & AI trading strategies: luxalgo.com
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Aviso legal
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Script de código aberto
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Get exclusive indicators & AI trading strategies: luxalgo.com
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Free 150k+ community: discord.gg/lux
All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.
Aviso legal
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.