[STRATEGY + EA CODE] XAU/USD 1-Min Scalping System (9/21 EMA + RSI)
Posted: Mon Aug 10, 2026 9:37 pm
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).
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
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.
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;
}
//+------------------------------------------------------------------+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