OPEN-SOURCE SCRIPT

Golden Trident | Swing-Anchored VWAP Trend System

9 368
Golden Trident is a long-only, daily-timeframe trend-following strategy built specifically for XAUUSD (spot gold). Rather than relying on a lagging moving-average crossover or a single volatility band, it reads market structure directly — tracking swing highs and lows to determine trend direction — and pairs that with a volume-weighted anchor price that resets at every structural trend change. This gives the strategy a "fair value" reference line that adapts to each new trend leg rather than dragging a fixed-length average behind it.

The strategy is deliberately long-only. Gold has spent most of its liquid trading history in a secular uptrend, and countertrend short entries were found to meaningfully drag down both total return and risk-adjusted performance without adding diversification benefit — so the system simply steps to the sidelines when structure turns bearish, rather than fighting the dominant trend.

Position sizing is intentionally simple: a fixed percentage of equity per trade, compounding as equity grows. Risk management is handled by a single wide "catastrophe" stop rather than a tight trailing stop — the strategy is designed to exit on genuine trend reversal, not to be shaken out by normal daily noise.

How It Works
  • Swing Structure (Trigger): The strategy tracks rolling swing highs and lows over a configurable lookback. When the most recent extreme is a new high, structure is bullish; when it's a new low, structure is bearish.
  • Anchored VWAP (Trend Reference): Each time structure flips, the volume-weighted average price calculation resets and begins accumulating fresh from that point — producing a trend-relative fair-value line rather than a static average.
  • EMA200 Filter (Structure Confirmation): Long entries additionally require price to be trading above the 200-period EMA, keeping trades aligned with the macro trend.
  • Chop Filter (Volatility Gate): Entries are blocked when recent price range is too narrow relative to ATR — this avoids entering on structural "flips" that occur during sideways consolidation, where they're most likely to reverse immediately.
  • Exit: Positions close purely on structural trend reversal. No trailing stop is used, since research during development found trailing exits tended to cap winning trades prematurely without meaningfully reducing losses.
  • Backstop Stop: A wide ATR-based stop exists purely as disaster protection for extreme, unexpected moves — it is not intended to be part of normal trade management.


Features
  • Swing-structure trend detection (not a lagging indicator crossover)
  • Self-resetting anchored VWAP trend reference
  • Optional EMA200 macro trend filter
  • Optional ATR-based chop/consolidation filter
  • Configurable backtest date range
  • Trade outcome visualization (colored boxes showing each closed trade's entry-to-exit range)
  • Live dashboard showing current structure, volatility state, position size, and open P/L
  • Gold-themed visual design with gradient trend fill and directional bar coloring


Tips for Use
  • Timeframe: Designed and tested on the daily chart. Shorter timeframes will likely need proportionally shorter swing/EMA/ATR lengths.
  • Data quality matters: Backtest only over periods with clean, liquid, consistently-quoted price and volume data. Very long historical ranges on XAUUSD may include gold-standard-era pricing or unreliable volume that will distort results — the built-in date range inputs default to 2010 onward for this reason.
  • Position sizing: The default equity percentage is aggressive. Test at a lower size first and scale up only after reviewing max drawdown and worst losing-streak length for your specific test window — position sizing should reflect your own risk tolerance, not just backtest profit factor.
  • Shorting: Short entries exist as a toggle for experimentation, but are off by default based on backtest performance on gold's historical trend bias. Re-enabling changes the strategy's risk profile meaningfully.
  • Not financial advice: This is a backtesting and educational tool. Past performance on historical data does not guarantee future results.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.