Strategy · Pine Script v6 · On the chart

XAUUSD Mean Reversion Strategy

by Young666YHF

This mean-reversion trading strategy targets XAUUSD during the Asian trading session.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code139
Settings10inputs
LicenceNone stated
Last update4 months ago9 Jun 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

XAUUSD Mean Reversion Strategy generates buy signals when price touches the lower Bollinger Band and RSI is oversold, and sell signals when price reaches the upper band and RSI is overbought. Trades are exited via an ATR-based stop loss, profit target at the previous bar VWAP, or a maximum holding time limit. User settings allow customization of Bollinger Band parameters, RSI thresholds, ATR stop loss multiplier, time window, and maximum holding bar count. The script overlays directly on the main price chart.

Details

Published by

Young666YHF on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Mean reversion, Sessions & time, Oscillators & momentum, Volatility & bands

Markets

Gold

Timeframes

M1-M5, M15-H1

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
布林带周期int20bb_period
布林带标准差float2.0bb_std
RSI周期int14rsi_period
RSI超卖阈值int25rsi_oversold
RSI超买阈值int75rsi_overbought
ATR周期int14atr_period
止损ATR倍数float1.0stop_loss_atr_mult
最大持仓K线数int5max_hold_bars
亚盘开始(北京时间)int6asian_start
亚盘结束(北京时间)int14asian_end
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

13 stars

This strategy overlays the price chart to trade DAX futures during European market hours. It calculates exponential and simple moving averages, RSI, MACD, Bollinger Bands, ATR, and realized volatility to simulate VIX levels. Trades execute when session time fi

Strategy v5 Sessions & timeOscillators & momentum
Updated 8 months ago · Custom licence GitHub repository of ClaudeHedge - DAX Session Strategy

RSI Mean Reversion

by GifariKemal
3 stars

This strategy plots entry signals, stop loss, take profit levels, and an information panel directly on the price chart. It combines a relative strength index mean reversion model with ATR percentile thresholds to filter trades based on volatility conditions. T

Strategy v5 Oscillators & momentumVolatility & bands
Updated 3 days ago · MIT GitHub repository of RSI Mean Reversion
330 stars

Alert BB + RSI [Alorse] is a multi-symbol mean-reversion strategy designed for cryptocurrency trading. It evaluates Bollinger Bands and the Relative Strength Index (RSI) across up to 20 user-defined ticker symbols simultaneously. The strategy enters long posit

Strategy v4 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of Alert BB + RSI [Alorse]
106 stars

A multi-timeframe Dollar Cost Averaging (DCA) trading strategy that combines signals from three RSI indicators, three CCI indicators, and Bollinger Bands. It places up to five weighted scale-in safety orders to lower the average entry price. The script offers

Strategy v5 Oscillators & momentumVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of 3RSI 3CCI BB 5orders DCA Strategy+
104 stars

This strategy combines Bollinger Bands with a short RSI to fade moves that leave the bands and then return. A long requires the prior bar below the lower band and oversold, then a close back inside the band while RSI is between 30 and 50. Shorts mirror that at

Strategy v5 Oscillators & momentumVolatility & bands
Updated 3 years ago · MIT GitHub repository of Bollinger Bands and RSI Strategy

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers