OPEN-SOURCE SCRIPT

Price Action Breakout Trend [QuantAlgo]

8 559
🟢 Overview

Price Action Breakout Trend is a trend-following indicator built on structural range breakouts rather than moving average crossovers or oscillator thresholds. It tracks the highest high and lowest low of a defined lookback window to establish the levels price must decisively clear to confirm a directional shift, anchoring a trailing stop that ratchets in the trend's direction and reverses only when price breaks through it, helping traders distinguish genuine trend continuation from the shallow pullbacks that punctuate every sustained move across all timeframes and markets.
istantanea
🟢 How It Works

The foundation of the indicator is the range defined by recent price extremes. On each bar it references the highest high and lowest low of the prior lookback window, excluding the current bar so the reference range is locked in before price interacts with it:
Pine Script®
prior_high = ta.highest(high, lookback)[1] prior_low = ta.lowest(low, lookback)[1]

These two levels frame the breakout boundaries. Rather than reacting to every marginal touch, the indicator lets you define what qualifies as a genuine break through the confirmation setting, which determines whether the closing price or the full bar extreme is tested against the trailing stop:
Pine Script®
test_down = confirmation == 'Close' ? close : low test_up = confirmation == 'Close' ? close : high

From these, a single trailing stop is maintained on the active side of the trend. While the trend holds bullish the stop ratchets upward, advancing to track the rising lookback low and never loosening, and the trend reverses the moment the tested price breaks below it:
Pine Script®
if trend == 1 trail := math.max(trail, prior_low) if test_down < trail trend := -1 trail := prior_high

On that reversal the stop immediately re-anchors to the opposite extreme, flipping above price to begin trailing the new downtrend, where the mirror of this same logic ratchets the stop lower and flips the trend back to bullish once price breaks above it. Because the reversal is triggered by the same stop price has been trailing, the line is not a passive overlay but the actual decision boundary, with no separate signal calculation sitting behind it. This makes the indicator a continuous stop-and-reverse system that always holds a committed direction, retaining its bullish or bearish reading through every pullback contained within the range until price clears the trailing level.
istantanea
🟢 Signal Interpretation

▶ Bullish Trend (Green): When price breaks above the trailing stop and the trend flips up, the indicator enters bullish mode with green coloring applied across the stop, gradient fill, and breakout levels. The stop sits below price and ratchets higher as the trend develops, and the reading holds through pullbacks that stay above it. The flip into green, marked by an up triangle beneath the bar, identifies a potential long/buy opportunity, with subsequent pullbacks toward the rising stop offering potential continuation entries while the trend remains intact.

▶ Bearish Trend (Red): When price breaks below the trailing stop and the trend flips down, the indicator enters bearish mode with red coloring across all visual elements. The stop sits above price and ratchets lower as the decline extends, holding bearish through rallies that fail to reclaim it. The flip into red, marked by a down triangle above the bar, identifies a potential short/sell opportunity, with rallies back toward the falling stop offering potential continuation entries on the downside.
istantanea
🟢 Features

▶ Preconfigured Presets: Three parameter sets cover different trading approaches. "Default" targets swing trading on 4-hour and daily charts with a 10-bar lookback and close-based confirmation, filtering marginal breaks while staying responsive to genuine shifts. "Fast Response" shortens the lookback to 5 bars and switches to wick-based confirmation for intraday charts, where the trend needs to flip as soon as price trades beyond a recent extreme. "Smooth Trend" extends the lookback to 25 bars with close confirmation for position trading on daily and weekly timeframes, where the cost of a false flip exceeds the cost of a delayed one. Selecting a preset overrides the individual lookback and confirmation inputs.
istantanea
▶ Built-in Alerts: Three alert conditions cover all directional states. "Bullish Breakout Signal" fires on the bar where the trend confirms bullish. "Bearish Breakout Signal" fires on the bar where it confirms bearish. "Any Breakout Signal" combines both into a single condition for traders who want a unified notification regardless of direction.
istantanea
▶ Visual Customization: Six color presets (Classic, Aqua, Cosmic, Cyber, Neon, and Custom) apply coordinated bullish and bearish schemes across the trailing stop, gradient fill, breakout levels, markers, and optional bar and background coloring. Independent toggles control each visual layer, so the trailing stop line, the gradient fill that ramps from the stop toward price, the triangle markers printed on each flip, and the underlying breakout levels that frame the active range can each be shown or hidden without affecting the others. Bar coloring tints price candles with the active trend color at a configurable transparency, and background coloring extends the directional tint across the full chart pane. Both are disabled by default and controlled independently.
istantanea
*Tips: Layer the Price Action Breakout Trend with complementary analysis rather than treating it as a standalone trading tool. Breakouts hold most reliably when backed by participation, so combine each flip with volume context, since a break on expanding volume is far more likely to sustain than one on thin flow, and read the level being cleared against market structure, as a breakout through a well-established swing high or low carries more significance than one in open space. Pairing this script with volume, open interest, CVD, market structure, and mean reversion indicators from our QuantAlgo toolkit can further validate a breakout before entry.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.