OPEN-SOURCE SCRIPT
Gold/Spread Algo

XAUUSD 1-Minute RSI Scalping Strategy – Mean-Reversion with Fixed Exits
This open-source strategy is a high-frequency, counter-trend scalping system designed specifically for **XAUUSD (Gold)** on the 1-minute timeframe.
Core Logic
The strategy uses classic RSI(14) to identify short-term overextension:
- Long entry when RSI drops below oversold (default 30) → expects quick snap-back
- Short entry when RSI rises above overbought (default 70) → expects quick pullback
Entries are taken only when flat (no pyramiding). Exits are fixed in pips and set immediately on entry:
- Take Profit: +10 pips (0.10 in XAUUSD price)
- Stop Loss: –5 pips (0.05 in XAUUSD price)
- Built-in Risk:Reward = 1:2
This fixed structure gives the system positive mathematical expectancy even with moderate win rates (≈55–65% before costs), provided gold continues to exhibit frequent mean-reversion behavior on 1-minute charts.
Why this simple approach?
Gold is one of the most volatile and momentum-driven instruments on very short timeframes. Pure RSI extremes often capture quick exhaustion moves after news spikes, order flow imbalances, or session transitions — especially during London/NY overlap. Fixed pip targets prevent over-optimization and mimic real broker execution more closely than dynamic trailing or percentage-based exits.
Important Realism & Backtesting Notes
To produce non-misleading results, use these settings when publishing/testing:
- Initial Capital: $10,000 – $30,000 (realistic retail size)
- Position sizing: fixed 0.10–0.30 lots or 1–3% equity per trade
- Commission: 5–8 USD round-turn per lot (typical ECN/raw-spread)
- Slippage: 3–8 ticks (≈0.03–0.08 in price) — gold spreads widen during volatility
- Minimum dataset: 12–36 months of 1-minute data (aim for 800–2000+ trades)
- Risk per trade: usually 0.5–1.5% with defaults — never exceeds sustainable levels
Results vary significantly:
- Strongest in ranging or mildly trending sessions
- Weaker during strong directional moves or major news (NFP, FOMC, geopolitics)
- Expect drawdowns during trending regimes — this is NOT a trend-following system
Visual & Dashboard Elements
- RSI line + fill (blue/orange background) + overbought/oversold zones
- BUY/SELL triangles at entry points
- Professional top-right dashboard showing:
- Net Profit & Loss
- Total Trades / Win Rate / Profit Factor
- Winning / Losing Trades
- Current RSI value
- Position status (LONG / SHORT / FLAT)
- TP:SL ratio
Alerts
- 🟢 LONG ENTRY – RSI oversold
- 🔴 SHORT ENTRY – RSI overbought
How to Use
1. Apply to XAUUSD 1-minute chart only
2. Use realistic commission/slippage in Strategy Tester
3. Trade primarily during London & New York sessions for best liquidity
4. Avoid major news events or widen stops manually
5. Forward-test on demo for 2–3 months minimum
6. Always size conservatively — never risk more than 1–2% per trade
Publish Recommendation
- Use a clean chart: only this strategy, no extra indicators/drawings
- Show realistic tester results with commission/slippage applied
- Screenshot during active session with visible entry signals + dashboard
Educational tool — open-source for learning and testing. Not financial advice. Gold 1-minute trading is extremely volatile and carries high risk of loss. Trade responsibly.
This open-source strategy is a high-frequency, counter-trend scalping system designed specifically for **XAUUSD (Gold)** on the 1-minute timeframe.
Core Logic
The strategy uses classic RSI(14) to identify short-term overextension:
- Long entry when RSI drops below oversold (default 30) → expects quick snap-back
- Short entry when RSI rises above overbought (default 70) → expects quick pullback
Entries are taken only when flat (no pyramiding). Exits are fixed in pips and set immediately on entry:
- Take Profit: +10 pips (0.10 in XAUUSD price)
- Stop Loss: –5 pips (0.05 in XAUUSD price)
- Built-in Risk:Reward = 1:2
This fixed structure gives the system positive mathematical expectancy even with moderate win rates (≈55–65% before costs), provided gold continues to exhibit frequent mean-reversion behavior on 1-minute charts.
Why this simple approach?
Gold is one of the most volatile and momentum-driven instruments on very short timeframes. Pure RSI extremes often capture quick exhaustion moves after news spikes, order flow imbalances, or session transitions — especially during London/NY overlap. Fixed pip targets prevent over-optimization and mimic real broker execution more closely than dynamic trailing or percentage-based exits.
Important Realism & Backtesting Notes
To produce non-misleading results, use these settings when publishing/testing:
- Initial Capital: $10,000 – $30,000 (realistic retail size)
- Position sizing: fixed 0.10–0.30 lots or 1–3% equity per trade
- Commission: 5–8 USD round-turn per lot (typical ECN/raw-spread)
- Slippage: 3–8 ticks (≈0.03–0.08 in price) — gold spreads widen during volatility
- Minimum dataset: 12–36 months of 1-minute data (aim for 800–2000+ trades)
- Risk per trade: usually 0.5–1.5% with defaults — never exceeds sustainable levels
Results vary significantly:
- Strongest in ranging or mildly trending sessions
- Weaker during strong directional moves or major news (NFP, FOMC, geopolitics)
- Expect drawdowns during trending regimes — this is NOT a trend-following system
Visual & Dashboard Elements
- RSI line + fill (blue/orange background) + overbought/oversold zones
- BUY/SELL triangles at entry points
- Professional top-right dashboard showing:
- Net Profit & Loss
- Total Trades / Win Rate / Profit Factor
- Winning / Losing Trades
- Current RSI value
- Position status (LONG / SHORT / FLAT)
- TP:SL ratio
Alerts
- 🟢 LONG ENTRY – RSI oversold
- 🔴 SHORT ENTRY – RSI overbought
How to Use
1. Apply to XAUUSD 1-minute chart only
2. Use realistic commission/slippage in Strategy Tester
3. Trade primarily during London & New York sessions for best liquidity
4. Avoid major news events or widen stops manually
5. Forward-test on demo for 2–3 months minimum
6. Always size conservatively — never risk more than 1–2% per trade
Publish Recommendation
- Use a clean chart: only this strategy, no extra indicators/drawings
- Show realistic tester results with commission/slippage applied
- Screenshot during active session with visible entry signals + dashboard
Educational tool — open-source for learning and testing. Not financial advice. Gold 1-minute trading is extremely volatile and carries high risk of loss. Trade responsibly.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.