OPEN-SOURCE SCRIPT

Strategy XAU/M5 RSI+EMA

93
XAU M5 Strategy — EMA + RSI with Flexible TP/SL

Recommended timeframe: M5
Best suited for: XAUUSD (Gold) — can also be tested on other pairs after optimization.

Concept

This strategy combines trend direction via EMA and momentum confirmation via RSI (oversold/overbought levels).

Buy (Long): when price is above EMA and RSI crosses above the oversold level.

Sell (Short): when price is below EMA and RSI crosses below the overbought level.

This method follows the trend but waits for RSI confirmation, avoiding premature entries during unconfirmed market moves.

Entry Conditions

Buy: close > EMA and RSI crossover RSI_oversold

Sell: close < EMA and RSI crossunder RSI_overbought

Default settings:

EMA Length = 500 (smooth trend filter for M5)

RSI Length = 8, Overbought = 70, Oversold = 30 (sensitive enough to catch early impulses)

Trade Management (TP/SL)

This strategy supports two TP/SL modes:

Fixed Value

Adds or subtracts a fixed price value directly from the entry price.

Example: TP = +14, SL = -7 (measured in price points, not USD).

Pip Mode

Uses pip size conversion: pip = syminfo.mintick * 10.

TP/SL = (entered pip value × pip size) added/subtracted from entry.

Note: although the inputs are labeled “USD/Pip,” the calculations are based on price points and pip-size scaling.
If you use a symbol other than XAUUSD, double-check pip size to ensure TP/SL aligns correctly.

Suggested Parameters (for XAUUSD M5)

EMA Length: 500

RSI Length: 8

RSI Overbought: 70

RSI Oversold: 30

TP/SL Mode: “Fixed Value” (easier for beginners)

TP (Value): 14

SL (Value): 7

Default risk–reward ratio ≈ 1:2 (TP twice the SL), ideal for fast-paced M5 scalping.

Usage & Optimization Tips

Use on M5 timeframe as designed. Adjust EMA/RSI if changing timeframes.

Select one TP/SL mode only (“Value” or “Pip”) and confirm actual units.

Avoid high-volatility news events (NFP, CPI, FOMC) to reduce slippage.

Focus on active sessions:

Gold is most volatile during London and New York sessions.

Risk management:

Risk ≤1–2% per trade.

Avoid countertrend stacking when RSI remains extreme in strong trends.

Trend confirmation:

EMA 500 filters noise well;

Backtesting Tips

Set initial capital realistically.

Include commissions/spread to mirror broker conditions.

Keep pyramiding low (0–1) to assess signal quality.

Start with On bar close mode, then test Every tick for detailed sensitivity.

Strengths

Simple and transparent: clear, rule-based signals.

Trend + momentum confirmation: avoids catching falling knives.

Flexible TP/SL system: switch easily between fixed or pip-based setups.

Limitations

RSI can trigger early during extended strong trends (persistent overbought/oversold).

TP/SL tuning is essential for each market and volatility regime.

Disclaimer

This is not financial advice.
Past performance does not guarantee future results.
Always backtest and paper trade before using real capital, and practice strict risk management.

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。