Gold Trail [XAUUSD] | Regime-Gated Adaptive ATR Strategy by blitz_locked

By blitz_locked

Performance Metrics

Description

A trend-following strategy for XAUUSD that trades only when gold is moving efficiently in one direction. It enters on the flip of an adaptive ATR trailing stop and uses that same trail as its protective stop. A regime filter keeps it flat during chop, which is where most trailing-stop systems lose money.How it worksRegime filter. The Kaufman Efficiency Ratio measures how directly price has moved compared with the total distance it travelled. That reading is ranked against gold’s own recent history (a percentile), so the filter calibrates itself to the timeframe you’re on instead of relying on a fixed number. Hysteresis and a minimum-bars timer stop the regime from flickering on and off. While the regime is dormant, the trail disappears, the candles can grey out, and no trades are taken.Adaptive trail. An ATR trailing stop ratchets in the direction of the trend and flips when price closes through it. Its distance widens when efficiency is low or volatility ranks high, and tightens in clean, calm trends. When a regime arms, a fresh trail is built from current price, so every trade starts from a genuine direction change.Entry filters. A flip only becomes a trade if all of these pass:Price is on the right side of the 50 EMA.There’s room to run: no long right under fresh pivot resistance, no short right above fresh pivot support.RSI isn’t stretched: no longs above 72, no shorts below 28.The trade is inside the session window (default 02:00–16:00 New York).The stop isn’t unreasonably tight.Risk and exits. Position size is a percentage of equity divided by the stop distance, capped by a leverage limit. Half the position closes at TP1 (1.2R). The rest targets TP2 (3R) or is stopped out by the trailing stop. A trail flip against an open trade closes it, or reverses it if the filters pass.FeaturesSelf-calibrating regime filter (no fixed threshold to retune per timeframe)Efficiency- and volatility-adaptive stop distancePivot S/R room-to-run filter and RSI no-chase filterRisk-based sizing with a leverage capTwo-stage exit: partial take profit, then the trail as a runner stopOptional session filter and optional exit when the regime goes dormantClean visuals: glow trail, fill to price, optional regime candles, optional S/R lines, entry labels, and stop/target markers while in a tradeCompact dashboard showing state, net profit, trades, win rate, profit factor and max drawdownTipsIt’s designed for the 15-minute to 1-hour charts. Test other timeframes separately, because the defaults are not tuned for them.If you get too few trades, lower “Arms above percentile” (say 55–60). If you get too many weak ones, raise it (70–75).The inputs most worth testing are the base trail distance, TP1/TP2 multiples, the room-to-run distance and the session window. Change one at a time.Set slippage and commission in the strategy properties to match your broker’s real spread. The default slippage is only a rough proxy.Check results across several different periods and market conditions (strong trends, ranges, high-volatility events), not just one stretch of data.Trades only open inside the session window, but open trades are still managed outside it.WarningsThis is a backtesting and research tool, not financial advice. Past results don’t predict future performance.Defaults are reasonable starting points, not optimised or proven settings. Over-tuning to one dataset will give flattering results that don’t hold up.Signals are evaluated on bar close and orders fill on the next bar’s open, so real fills will differ from the signal bar’s price, especially in fast markets.Pivot levels are only confirmed several bars after they form, so the S/R filter reacts with a delay.There’s no news or event filter. Gold can gap or spike through a stop on data releases, so live losses can exceed the planned risk.Backtests on TradingView can’t model real spreads, requotes or rejected orders. Gold spreads widen sharply around news and at rollover.Leverage on gold is risky. Use the leverage cap and keep per-trade risk small.Trend strategies often lose repeatedly in choppy markets, even with a regime filter. Expect losing streaks.

Browse all 5,900+ TradingView Pine Script strategies

View on TradingView