Page 1 of 1

[STRATEGY + EA CODE] XAU/USD 1-Min Scalping System (9/21 EMA + RSI)

Posted: Mon Aug 10, 2026 9:37 pm
by FTtrader
Hey fellow scalpers at forex-scalping.com!

If you’ve been trading Gold (XAU/USD) recently, you know it moves with incredible velocity. While that volatility can blow up an unmanaged account, it’s exactly what we need for a tight, systematic scalping strategy.

Today, I’m sharing a complete EMA + RSI Trend-Following Scalper designed specifically for the 1-minute (M1) and 5-minute (M5) charts. This setup keeps you on the right side of the institutional trend while using fast crossovers for pinpoint entries.

I’ve also coded the logic into a lightweight MT4 Expert Advisor (EA) so you can backtest it or run it on a demo account.

The Setup & IndicatorsWe are keeping our charts clean and relying only on moving averages to identify trend/momentum, and the RSI to ensure we aren't buying at the top or selling at the bottom.Timeframe: M1 or M5Asset: XAU/USD (Gold)200 EMA (Exponential Moving Average): Our master trend filter.21 EMA: Our slow momentum baseline.9 EMA: Our fast trigger line. RSI (14-period): Set a horizontal line at the 50 level.📜 Trading RulesWe only take trades in the direction of the 200 EMA to avoid getting crushed by sudden market corrections. Here are the exact triggers:Condition🟢 LONG (Buy) Setup🔴 SHORT (Sell) SetupTrend FilterPrice must be above the 200 EMAPrice must be below the 200 EMATrigger Signal9 EMA crosses above the 21 EMA9 EMA crosses below the 21 EMAMomentum (RSI)RSI is > 50 (but strictly < 70 to avoid overbought)RSI is < 50 (but strictly > 30 to avoid oversold)Stop Loss (SL)20-30 pips (Below the recent swing low)20-30 pips (Above the recent swing high)Take Profit (TP)40-60 pips (1:2 Risk-Reward ratio minimum)40-60 pips (1:2 Risk-Reward ratio minimum)

The MT4 Expert Advisor (MQL4 Code)
If you want to automate the alerts or execution, here is the MQL4 source code. It executes trades on the close of the bar to prevent repainting and false signals.

How to use:

1.) Open MetaEditor in MT4 (F4).

2.) Create a new Expert Advisor named XAUUSD_EMA_RSI_Scalper.

3.) Paste the code below and hit Compile.

4.) Important: Adjust the StopLossPoints and TakeProfitPoints to match your broker's digit structure. For a standard 2-decimal gold broker, 1 pip = 10 points (so 300 points = 30 pips).

Code: Select all

//+------------------------------------------------------------------+
//|                                     XAUUSD_EMA_RSI_Scalper.mq4   |
//|                                           forex-scalping.com     |
//+------------------------------------------------------------------+
#property copyright "forex-scalping.com Community"
#property link      "https://forex-scalping.com"
#property version   "1.00"
#property strict

//--- Input parameters
input double LotSize          = 0.01;      // Trade Lot Size
input int    StopLossPoints   = 300;       // Stop Loss in Points (e.g., 300 = 30 pips)
input int    TakeProfitPoints = 600;       // Take Profit in Points (e.g., 600 = 60 pips)
input int    MagicNumber      = 55555;     // Magic Number for EA

input int    FastEmaPeriod    = 9;         // Fast EMA Period
input int    SlowEmaPeriod    = 21;        // Slow EMA Period
input int    TrendEmaPeriod   = 200;       // Trend EMA Period
input int    RsiPeriod        = 14;        // RSI Period

//--- Global variables
datetime timePrev = 0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit() {
    Print("XAUUSD Scalper EA Initialized. Ready to hunt pips.");
    return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick() {
    // Only execute on a newly closed bar to prevent repainting/false triggers
    if(timePrev == Time[0]) return;

    // Ensure we only have one trade open at a time
    if(OrdersTotalOpen() > 0) return; 

    // Calculate indicators on the last closed bar (Shift 1) and the one before (Shift 2)
    double emaFast_1 = iMA(Symbol(), 0, FastEmaPeriod, 0, MODE_EMA, PRICE_CLOSE, 1);
    double emaFast_2 = iMA(Symbol(), 0, FastEmaPeriod, 0, MODE_EMA, PRICE_CLOSE, 2);
    
    double emaSlow_1 = iMA(Symbol(), 0, SlowEmaPeriod, 0, MODE_EMA, PRICE_CLOSE, 1);
    double emaSlow_2 = iMA(Symbol(), 0, SlowEmaPeriod, 0, MODE_EMA, PRICE_CLOSE, 2);
    
    double emaTrend_1= iMA(Symbol(), 0, TrendEmaPeriod, 0, MODE_EMA, PRICE_CLOSE, 1);
    double rsi_1     = iRSI(Symbol(), 0, RsiPeriod, PRICE_CLOSE, 1);
    
    double close_1   = Close[1];

    // Determine Overall Trend
    bool isUptrend   = close_1 > emaTrend_1;
    bool isDowntrend = close_1 < emaTrend_1;

    // Determine Crossovers
    bool crossUp   = (emaFast_2 <= emaSlow_2) && (emaFast_1 > emaSlow_1);
    bool crossDown = (emaFast_2 >= emaSlow_2) && (emaFast_1 < emaSlow_1);
    
    // RSI Conditions (Filtering out extreme overbought/oversold levels)
    bool rsiBullish = (rsi_1 > 50.0 && rsi_1 < 70.0);
    bool rsiBearish = (rsi_1 < 50.0 && rsi_1 > 30.0);

    // BUY LOGIC
    if(isUptrend && crossUp && rsiBullish) {
        double sl = Ask - (StopLossPoints * Point);
        double tp = Ask + (TakeProfitPoints * Point);
        
        int ticket = OrderSend(Symbol(), OP_BUY, LotSize, Ask, 3, sl, tp, "XAUUSD Buy", MagicNumber, 0, clrBlue);
        if(ticket > 0) timePrev = Time[0];
    }
    
    // SELL LOGIC
    else if(isDowntrend && crossDown && rsiBearish) {
        double sl = Bid + (StopLossPoints * Point);
        double tp = Bid - (TakeProfitPoints * Point);
        
        int ticket = OrderSend(Symbol(), OP_SELL, LotSize, Bid, 3, sl, tp, "XAUUSD Sell", MagicNumber, 0, clrRed);
        if(ticket > 0) timePrev = Time[0];
    }
}

//+------------------------------------------------------------------+
//| Custom function to check open orders for this specific EA        |
//+------------------------------------------------------------------+
int OrdersTotalOpen() {
    int count = 0;
    for(int i = OrdersTotal() - 1; i >= 0; i--) {
        if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
            if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
                count++;
            }
        }
    }
    return count;
}
//+------------------------------------------------------------------+
Run this in the Strategy Tester first to optimize the StopLossPoints and TakeProfitPoints for your specific broker’s spread profile.

Let me know in the thread how this setup works for you, or if you modify the code to include trailing stops! Happy hunting. 📈
Take a care :-)

Re: [STRATEGY + EA CODE] XAU/USD 1-Min Scalping System (9/21 EMA + RSI)

Posted: Fri Sep 11, 2026 7:42 pm
by LondonScalper
FTtrader wrote:Today, I’m sharing a complete EMA + RSI Trend-Following Scalper designed specifically for the 1-minute (M1) and 5-minute (M5) charts.
Clean enough skeleton — 9/21 for impulse, slower EMA for location, RSI as a “don’t chase the extreme” filter. That pattern has been reinvented under many names.

Where gold M1 usually punishes it: the crossover fires after the impulse you wanted, and RSI still looks “fine” while you’re buying the first pause that becomes a full mean-reversion. On XAU the cost of being late is not a pip — it’s a few dollars of noise before your stop logic even wakes up.

Desk habits if I ever run something like this semi-auto:
  • Session filter hard (London / early NY overlap only)
  • No new entries in the 2–3 minutes around tier-1 US prints
  • Measure expectancy after typical gold spread+slip, not on pristine ticks
The EA is useful as a lab notebook, not as a set-and-forget. Curious what your forward window looked like on the same broker you’ll go live with — demo fills on gold lie cheerfully.

Re: [STRATEGY + EA CODE] XAU/USD 1-Min Scalping System (9/21 EMA + RSI)

Posted: Mon Sep 21, 2026 7:38 pm
by LondonNewsTrader
FTtrader wrote:If you’ve been trading Gold (XAU/USD) recently, you know it moves with incredible velocity. While that volatility can blow up an unmanaged account, it’s exactly what we need for a tight, systematic scalping strategy.
Velocity is the product and the hazard. EMA+RSI on M1 only works if costs and news risk are treated as first-class rules.

London habit: 200 EMA as bias is fine; I will not stack 9/21 crosses into a Tier-1 US print or when gold's spread is already half the target. RSI mid-line filters stop some chase entries, but they do not replace a flat window around CPI/NFP. An MT4 EA that backtests cleanly on M1 gold can still bleed live once slip and stops-on-spikes appear.

I prefer the same logic on M5 when the calendar is heavy — fewer tickets, more of the move left after friction.

Do you disable the EA entirely inside blackout minutes, or only block new entries while letting open risk run?

Re: [STRATEGY + EA CODE] XAU/USD 1-Min Scalping System (9/21 EMA + RSI)

Posted: Sun Sep 27, 2026 4:41 pm
by PropScalpDesk
One mismatch between the rules and the EA: the rules put the stop 20 to 30 pips below the recent swing low, but the code uses a fixed StopLossPoints = 300 from the entry price and never looks at a swing. Anyone backtesting the EA is testing a different system from the one in the table.

Watch the point maths on gold too. On a 2-decimal XAUUSD quote Point is 0.01, so 300 points is $3.00. Plenty of brokers quote gold with 3 decimals, though, and on those the same input gives a $0.30 stop, which the spread alone can hit. Converting from a price distance (for example SL in dollars, divided by Point) avoids that.

The slippage argument of 3 in OrderSend is 3 points, i.e. 3 cents on gold. During a fast M1 move on an instant-execution account that will produce requotes, and since timePrev is only set when a ticket succeeds, the EA keeps retrying on every tick of that bar at whatever price is current by then. I'd set it to something like 30 and log the failures.