OPEN-SOURCE SCRIPT
Updated

Adaptive Regression Breakout Map | GainzAlgo

9 869
The Adaptive Regression Breakout Map (ARBM) is an advanced volatility and trend-tracking system designed to identify periods of extreme market compression and automatically map out high-probability breakout trades.

Rather than relying on traditional lagging indicators, ARBM utilizes a continuous statistical baseline to measure market "squeezes." Once a breakout is confirmed, the indicator shifts from analysis into execution mode, drawing a dynamic visual map on your chart that outlines precise Entry, Stop Loss, and Take Profit (TP1, TP2, TP3) levels, complete with automated trailing stop logic and a live performance dashboard.

How It Works

At its core, the ARBM operates on a dual-engine architecture:

  1. Statistical Compression (The Squeeze): The script calculates a rolling linear regression baseline and wraps it in standard deviation bands. It continuously measures the width of this channel and compares it to a historical lookback period. When the bandwidth drops into a historically low percentile, the bands change color, signaling that the market is in a "squeeze" and building energy for a move.
  2. Auto-Trendlines: Alongside the statistical bands, the script plots dynamic, auto-trendlines across recent pivot highs (cyan) and lows (magenta). These holographic lines track geometric compression and leave a visual history on the chart.
  3. The Breakout Trigger: A signal is generated when the price violently escapes either the statistical standard deviation bands or the geometric auto-trendlines while the market is in a confirmed contraction state.
  4. Dynamic Trade Mapping: Upon a breakout, the script calculates targets based on the volatility (bandwidth) at the time of the breakout. It plots the trade directly on your chart and actively trails the stop loss as targets are hit.


The Settings and Selections

The indicator is highly customizable, divided into four primary control groups:

Regression Model:

  • Regression Length: The lookback period for the linear regression baseline.
  • Deviation Multiplier: The width of the statistical bands (similar to Bollinger Bands).


Contraction Metrics:

  • Lookback Period: How far back the script looks to determine if the current channel is historically narrow.
  • Contraction Threshold %: The percentile the bandwidth must drop below to trigger a "squeeze" state.


Target Architecture:

snapshot

  • TP1, TP2, TP3 Multipliers: Determines how far away your take profit targets are, dynamically scaled by multiplying the width of the channel at the time of the breakout.


Trendlines Overlay:

snapshot

  • Show Holographic Trendlines: Toggle the geometric trendlines on or off.
  • Pivot Length: Determines how sensitive the script is when identifying the swing highs and lows used to draw the trendlines.


How to Use It

Trading with the ARBM is highly visual and systematic:

  • Wait for the Squeeze: Watch the regression channel. When the bands turn gray, volatility has compressed, and the market is consolidating.
  • Wait for the Signal: Look for a "Breakout, Long" or "Breakout, Short" label to appear. This confirms price has broken structure with momentum.
  • Follow the Map: The script will immediately draw your Entry (Blue), Stop Loss (Red), and three Take Profit targets (Green dashed lines).
  • Manage the Trade: The indicator handles trade management visually.


  1. When TP1 is hit, the Stop Loss line automatically moves to your Entry price (Breakeven), and a label confirms the trail.
  2. When TP2 is hit, the Stop Loss trails to TP1.
  3. When TP2 is hit, the Stop Loss trails to TP1.


snapshot

  • The trade closes entirely if TP3 or the trailing stop is hit. (Note: Hitting TP1 secures a win for the system's tracking, even if the remainder is stopped out at breakeven).
  • Monitor Performance: A stylized dashboard in the top right corner tracks the total number of signals, the historical Win Rate, and the Trade-by-Trade Sharpe Ratio, allowing you to quickly validate the settings for any given asset or timeframe.


Final Thoughts

The Adaptive Regression Breakout Map removes the guesswork from breakout trading. By combining continuous statistical volatility tracking with futuristic geometric trendlines, it mathematically identifies when a market is ready to move. Furthermore, by drawing the exact risk-to-reward parameters on the chart and tracking its own historical performance, it forces strict risk management and objective trade execution.
Release Notes
Improved some calculations and refined the chart UI for a better user experience.

Disclaimer

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.