β¨ Originality and Utility
The classic NRTR trailing stop is normally computed directly from price. This script decouples the “source” the trailing calculation reacts to from raw price by routing it through a selectable adaptive filter stage first β SMA, EMA, RMA, Double WMA, Triple VWMA, HMA, a custom LLAMA slope-projection filter, or a Kalman filter. This means the trailing envelope itself can be smoothed, decoupled from tick-level noise, or shaped to lag less than a conventional moving average, without changing the core NRTR ratchet-and-flip mechanic.
Beyond the trailing engine, the script closes the loop between “signal” and “trade management,” which most trailing-stop tools leave to the user. Once a trend flip is confirmed, it automatically derives a stop-loss from the NRTR level itself and projects three risk-multiple take-profit targets, tracks whether each has been hit, calculates a suggested position size from a risk percentage or fixed-dollar risk model, and optionally suppresses new signals for a cooldown period after a stop-out. An ADX confluence filter can additionally require a minimum trend strength reading before a flip is treated as valid. The combination is justified because each component consumes the output of the one before it: the adaptive filter conditions the source, the NRTR logic converts that source into a trailing stop and flip signal, the ADX filter validates the flip’s context, and the risk/sizing engine turns the validated flip into an actionable, fully quantified trade plan β a single coherent pipeline rather than an arbitrary bundling of unrelated indicators.
π¬ Methodology and Concepts
β’ The Adaptive Source Filter
Before any trailing-stop math happens, closing price is optionally passed through one of these transformations, selected from the “Adapt Filter” input:
- SMA / EMA / RMA β standard moving averages, included as familiar baselines.
- Double WMA β a Weighted Moving Average applied twice in succession (a WMA of a WMA), which produces a lower-lag response than a single WMA of the same length.
- Triple VWMA β a Volume Weighted Moving Average cascaded three times, folding volume-weighting into a lower-lag smoothing chain.
- HMA β the Hull Moving Average, using weighted-moving-average differencing to reduce lag relative to standard smoothing.
- LLAMA β a proprietary two-part filter that combines a simple moving average of the source with a linear slope term measured over the same lookback (the rate of change between the current source value and the value from `length` bars ago, divided by `length`). The slope is scaled by half the filter length and added to the SMA, producing a trend-projected estimate that leans ahead of a plain average in the direction of the recent slope.
- Kalman Filter β a lightweight recursive estimator that updates a running estimate of the “true” price using a prediction/correction cycle. It maintains an internal error estimate and a gain term derived from the ratio of process noise (set by the inverse of the filter length) to measurement noise, blending each new price observation into the estimate proportionally to that gain.
- None β the trailing logic operates directly on closing price.
When “None” is selected, the tool behaves as a standard price-based NRTR. Any other selection substitutes that smoothed series as the “source” for every downstream calculation.
β’ NRTR Trailing Calculation
The script offers two modes for sizing the trailing offset, chosen via “NRTR Mode”:
- Percent β the offset is a fixed percentage of the (lagged) adaptive source value.
- ATR β the offset is a multiple of the Average True Range over a configurable lookback, scaling the trailing distance to current volatility rather than a fixed percentage.
In an uptrend, the script tracks the highest adaptive-source value reached since the last flip (the “extreme”) and subtracts the offset from it to produce a trailing level that can only rise or stay flat β never fall β while the trend persists. In a downtrend, the mirror logic tracks the lowest extreme and adds the offset, producing a level that can only fall or stay flat. A trend flip occurs the moment the prior bar’s adaptive source closes beyond the trailing level: closing below it in an uptrend flips the state to a downtrend (and vice versa), at which point the extreme and trailing level reset and begin tracking in the new direction. Because the ratchet only ever tightens toward price, this produces the classic NRTR “stair-step” trailing behavior rather than a smooth curve.
β’ Confirmation and Non-Repainting Behavior
The trend-state comparison that triggers a flip always references the previous bar’s confirmed adaptive-source value, and every alert condition is additionally gated behind `barstate.isconfirmed`. This means a signal only fires once its triggering bar has fully closed β the trailing level and trend state do not repaint once a bar is confirmed, and alerts cannot fire prematurely intrabar.
β’ ADX Confluence Filter
When enabled, a flip is only accepted as a valid trading signal if the prior bar’s ADX reading (calculated over the same configurable length for both DI and ADX smoothing) is at or above the threshold input. This is intended to suppress flips that occur while the market lacks directional strength, where trailing-stop whipsaws are most common.
β’ Cooldown Guard
When enabled, a stop-loss hit on one side of the market starts a bar-count cooldown during which a new signal in that same direction is suppressed, intended to reduce immediate re-entry into a level that has just failed.
β’ Trade Level Projection and Position Sizing
On a valid signal, the entry is taken at the current close, the stop-loss is set to the NRTR trailing level at that moment, and the initial risk distance (entry-to-stop) is multiplied by three independently configurable multiples to project TP1, TP2, and TP3. Each target and the stop are tracked bar-by-bar for whether price has traded through them, updating their on-chart labels accordingly. A suggested position size is calculated from either a percentage of a user-defined account size or a fixed dollar risk amount, divided by the entry-to-stop distance in price, giving a size that risks a consistent dollar or percentage amount regardless of current volatility.
π¨ Visual Guide
- NRTR Line β a grey step-line plotting the current trailing-stop level.
- Heatmap Candles β the chart’s candles are recolored using the Bull/Bear color inputs (teal/red by default) to reflect the current trend state directly on price, rather than requiring a separate indicator pane.
- Cooldown Background β a shaded background tint appears while a directional cooldown is active after a stop-out, using the Cooldown BG color.
- Trade Level Lines and Labels (on signal) β a solid red Stop Loss line, a dashed blue Entry line, and three dashed green Take Profit lines (TP1 lightest, TP3 most opaque) extend from the signal bar. Each carries a right-aligned label showing its exact price; once a target or stop is touched, its label updates in place to show the hit and the resulting percentage gain or loss from entry.
- Risk/Reward Shading β a light red fill shades the zone between Entry and Stop Loss (the risk side), and a light green fill shades the zone between Entry and TP3 (the full reward side), giving an immediate visual sense of the trade’s risk-to-reward geometry.
- Dashboard Table β a corner-anchored panel (position configurable) summarizing, in real time: current trend direction, Lock status, the live NRTR level, active entry/stop/TP1 prices, the current ADX reading (colored by pass/fail against the threshold), the active adaptive filter, cooldown status and remaining bars, the calculated risk amount, the suggested position size, and a filled bar-graph showing how close price currently sits to the trailing stop as a percentage of the total offset distance.
π How to Use
- A flip from red to teal candles (and the NRTR line stepping below price) signals a potential long entry; the mirror flip signals a potential short.
- Use the auto-drawn Entry, Stop Loss, and Take Profit lines as a starting risk/reward framework β the SL is anchored to the trailing level at the moment of the flip, not an arbitrary distance.
- Enable the ADX Filter if you want flips confirmed only during periods of measurable trend strength, which reduces (but does not eliminate) signals generated in choppy, low-ADX conditions.
- Enable Cooldown Guard if you want to avoid immediate re-entry into a direction that was just stopped out β useful in ranging conditions prone to repeated whipsaws.
- Enable Lock Signal to freeze the currently displayed trade levels in place (rather than having them update to the latest signal), useful for reviewing a specific historical setup without it being overwritten by newer signals.
- Watch the “Dist Trail” bar in the dashboard as a quick visual read of how far price currently sits from the trailing stop relative to the configured offset β a nearly full bar means price is close to triggering a flip.
- The built-in alert payloads are formatted as JSON and include action, ticker, timeframe, direction, entry, stop, and target fields, making them usable directly as webhook bodies for external automation without additional parsing.
βοΈ Inputs and Settings
- NRTR Mode β switches the trailing offset calculation between a fixed Percent of price and a volatility-adaptive ATR multiple.
- NRTR % / ATR Len / ATR Mult β control the magnitude of the trailing offset in each respective mode; larger values produce a looser trail with fewer, later flips, smaller values produce a tighter trail with more frequent flips.
- Use ADX Filter / ADX Len / ADX Thresh β toggle and configure the trend-strength confluence filter described above.
- Adapt Filter / Adapt Len β select the smoothing method applied to price before the NRTR calculation, and its lookback length.
- Cooldown Guard / Cooldown Bars β toggle and configure the post-stop-out re-entry suppression window.
- Lock Signal β freezes the currently plotted trade levels rather than letting them advance to the newest signal.
- Position Sizing / Sizing Mode / Risk % Trade / Fixed Risk $ / Account $ β configure whether suggested size is derived from a percentage of account equity or a fixed dollar risk figure, and the inputs feeding that calculation.
- TP1/TP2/TP3 Mult β the risk multiples applied to the entry-to-stop distance to project each take-profit level.
- Heatmap Candles / NRTR Line / Trade Levels β independently toggle each visual layer on or off.
- Dash Pos / Show Dash β position and visibility of the dashboard table.
- Alert Action fields (Long/Short/Close Long/Close Short) β customize the “action” string embedded in each webhook JSON payload, useful for matching the field names expected by a specific external automation system.
- Color inputs β independently customize every plotted and dashboard color.
π Deconstruction of the Underlying Scientific and Academic Framework
The NRTR mechanic itself belongs to a family of stop-and-reverse trailing systems related conceptually to Wilder’s Parabolic SAR and to chandelier-style trailing stops: all three share the property that the trailing level is a one-directional ratchet β it can only move in the direction that tightens toward price β which is what mechanically prevents the trailing stop from ever “giving back” more than the configured offset once a trend is underway. Where NRTR differs is in decoupling the ratchet from a fixed acceleration curve (as in Parabolic SAR) and instead deriving it directly from a percentage or volatility-scaled offset off a tracked local extreme, which is closer in spirit to a Donchian- or Chandelier-style trailing construction.
The ATR-based offset mode draws on Welles Wilder’s concept of using recent true-range volatility, rather than a fixed percentage, to size a trailing distance β the rationale being that a constant percentage offset is too tight in high-volatility regimes (generating premature stop-outs) and too loose in low-volatility regimes (giving back excess profit), while an ATR-scaled offset expands and contracts with the instrument’s own recent behavior.
The Double WMA and Triple VWMA filters are cascaded-smoothing constructions in the same family as Hull’s differencing approach: repeatedly passing a series through a weighted average and recombining the outputs is a general technique for pushing a smoothing filter’s group delay down without simply shortening its lookback (which would otherwise increase noise sensitivity). The Kalman filter option applies a simplified, single-state version of the classic recursive Bayesian estimator from control theory, where each new observation is blended into a running estimate according to a gain term balancing assumed process noise against assumed measurement noise β conceptually the same estimation framework used in tracking and signal-processing applications outside of finance. The custom LLAMA filter combines a central-tendency estimate (a simple moving average) with a first-order trend term (a discrete slope measured over the same window), an approach related in principle to linear trend-projection and regression-based smoothing techniques that attempt to reduce lag by explicitly modeling the direction a series is moving rather than only its recent average level.
The ADX component derives from Wilder’s Directional Movement System, in which ADX quantifies the strength (not direction) of a trend by smoothing the divergence between positive and negative directional movement β using it as a confluence filter reflects the broader technical-analysis principle that trend-following and trailing-stop methods perform better in the specific market regime (trending, directional) they are designed for, and using a strength filter is one common approach to distinguishing that regime from a ranging one.
β οΈ Disclaimer
All provided scripts and indicators are strictly for educational exploration and must not be interpreted as financial advice or a recommendation to execute trades. We expressly disclaim all liability for any financial losses or damages that may result, directly or indirectly, from the reliance on or application of these tools. Market participation carries inherent risk where past performance never guarantees future returns, leaving all investment decisions and due diligence solely at your own discretion.
Source link
Author

- Ytv Market News
- Share-market news writer and analyst with deep experience covering equities, commodities, forex, and cryptocurrencies for readers in the USA, UK, Canada, and Australia. Ytv Market News delivers timely market updates, practical trading insights, and clear explanations of macro and company-level catalysts that move prices. Combines on-the-ground financial reporting with technical analysis, using concise charts and actionable ideas to help investors and traders make smarter decisions.
Latest entries
Market Movers TodayAugust 27, 20265 Must-Read Analyst Questions From Flowers Foodsβs Q2 Earnings Call
Forex NewsAugust 27, 2026Japanese yen edges higher before Tokyo CPI and Fed’s Warsh on Friday
IndiaAugust 27, 2026Skyways, Symbiotec, Hy Tech Engineers IPOs see strong subscription on final day
Company Press ReleasesAugust 27, 2026Net Asset Value(s) – Janus Henderson USD AAA CLO Active Core UCITS ETF
