Pipsgrowth EX18093 TrendFollow
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX18093 main — RSI scalping with target exits, full 12-layer stack.
Overview
EX18093 is a single-position RSI scalper for XAUUSD on M5 that trades the moments when the 14-period RSI leaves a narrow 46 to 49 dead zone, then rides the move until the same RSI reaches a stretched target (85 long, 35 short) or a 10-bar against-counter expires the trade.
The EA's design starts with an unusual RSI threshold setup. Instead of the textbook 30/70 oversold/overbought markers, the entry gates sit at 46 (oversold) and 49 (overbought), which is a 3-point band centered on the equilibrium line. A buy only fires when the bar two periods ago printed at or below 46 and the previous bar closed above 46, meaning a confirmed cross back into the upper half from extreme weakness. A sell mirrors that pattern: bar[2] is at least 49 and bar[1] falls below 49. The two-bars-ago requirement eliminates the whipsaw that a single-bar cross produces when RSI oscillates around a flat mid-line.
Once a position is open, the RSI target exit dominates the trade. A long closes when current RSI climbs to 85 or above, betting that the move has stretched far enough to take profit. A short closes when RSI falls to 35 or below. These are aggressive targets, typically 35 points of travel from a typical entry in the 50s to either extreme, so the EA is structurally a let-the-mean-reversion-extend design rather than a tight scalper.
Sitting underneath the target logic is a counter that tracks bars where the RSI has moved against the position. For a long, against means RSI dropped back below the 46 oversold line. For a short, against means RSI rallied back above the 49 overbought line. Each closed bar in that adverse state increments bars_against_count. When the count reaches the BarsToWait input (default 10), the position closes regardless of where price is. The counter resets the moment RSI returns into the position-friendly zone, so a brief dip below 46 that quickly recovers does not close the trade. Only sustained adverse RSI does.
The order layer uses the CTrade wrapper with ORDER_FILLING_FOK and a 3-point slippage allowance. There are no protective stops or take-profits attached to the order at open, so both the 0 SL and 0 TP are passed to trade.Buy() and trade.Sell() explicitly. Risk control is delegated entirely to the bars-against counter and the RSI target exit. There is no hard stop loss in price terms. LotSize is a fixed input (default 0.10 lots) with no risk-percent, no balance-based sizing, and no drawdown cap in the visible source. The capital cap layer from the 12-layer stack label in the header is not actually implemented in this build.
The OnTick() handler processes signals only on a new bar of the user-selected timeframe (default H1 in the source's MapTimeframeInt switch, though the EA's intended chart timeframe is M5). It calls UpdateRSI() to copy three bars of the indicator, then CheckExistingPosition() to apply the target or timeout logic if a position is open, then CheckEntrySignals() to look for the cross if no position is open. This single-position gate means the EA never pyramids and never hedges itself. One trade in flight at a time, identified by its ticket.
Three retry helpers (TryClose_EX18093, TryClosePartial_EX18093, TryModify_EX18093) wrap the CTrade calls and absorb requote, timeout, price-off, and price-changed errors with 200 ms or 100 ms sleeps and up to three attempts. While this build never calls TryModify (no SL or TP is ever modified), the helper is present for future extension. The TryClose path is the one in active use.
There is no OnTester() formula, no chart info panel, no news filter, no session filter, no spread filter, and no multi-timeframe confirmation. The EA runs 24/5 on whatever symbol and timeframe the user attaches it to. The MagicNumber input is fixed at 22218093 but is exposed for the user to change, and the trade comment defaults to Psgrowth.com Expert_18093 so positions are easy to identify in the trade panel and in the broker history.
Practical expectations: the narrow 46/49 entry band means most bars produce no signal. The EA is patient, waiting hours or days for a clean cross out of the dead zone. When that cross lands, it commits 0.10 lots with no protective stop, which is the single biggest risk in the design. Run it on a low-spread XAUUSD broker, keep the chart on M5 (the strategy was developed on that timeframe even though the indicator defaults to H1 in the switch), and use the trade comment to filter the strategy's positions in your broker's history.
The MagicNumber, Slippage, and LotSize are the only three inputs the user is likely to touch on a live install. RSI_Period, RSI_Overbought, RSI_Oversold, RSI_Target_Buy, RSI_Target_Sell, and BarsToWait are strategy-level dials that should be re-tuned only with backtest evidence; tightening the band further to 47/48 will sharply reduce trade frequency, while raising BarsToWait from 10 toward 20 lets adverse RSI stretches survive longer in the hope of a target exit. Be aware that the EA's source file declares two duplicate copies of MapTimeframeInt, MapAppliedPriceInt, g_TimeFrame, and g_RSI_Applied_Price (a leftover template artifact that the compiler silently absorbs) and applies the value of TimeFrame via a single assignment in OnInit, so the runtime behavior is unaffected despite the visible redundancy.
Strategy Deep Dive
EX18093 attaches a single iRSI handle on the user-selected timeframe and updates three bars of it once per closed bar via UpdateRSI(). On a new bar, OnTick() calls CheckExistingPosition() to apply the 85/35 target-exit logic or the 10-bar against-counter timeout, then CheckEntrySignals() to look for the 46/49 cross out of the dead zone. The retry helpers TryClose, TryClosePartial, and TryModify wrap CTrade.PositionClose and absorb requote, timeout, and price errors with up to three 200 ms attempts. There is no OnTester formula, no info panel, no spread filter, no session filter, and no news gate, so the EA runs 24/5 on the attached chart.
EX18093 enters on a confirmed two-bar RSI(14) cross out of a narrow dead zone. A buy requires bar[2] <= 46 and bar[1] > 46 (RSI leaving oversold), and a sell requires bar[2] >= 49 and bar[1] < 49 (RSI leaving overbought). The trade uses a fixed LotSize of 0.10 with no SL or TP attached at open.
A long position closes when the current RSI reaches or exceeds the 85 buy target; a short closes when RSI falls to or below the 35 sell target. If RSI moves against the position (long: RSI<46, short: RSI>49) for BarsToWait=10 consecutive closed bars, the EA force-closes the trade via a counter that resets the moment the indicator returns to the friendly side. There is no price-based stop loss in the design.
EX18093 attaches no protective stop loss to the order (trade.Buy/Sell receive 0 for both SL and TP). The closest thing to a stop is the bars_against_count timer, which force-closes a long after 10 bars of RSI<46 or a short after 10 bars of RSI>49. This is a soft, indicator-based stop rather than a price stop.
Take-profit is also a zero at open with no price-based TP. The functional TP is the RSI target exit: long closes at RSI>=85, short closes at RSI<=35. These are extreme RSI levels, so the EA lets winning mean-reversion trades run a long way before banking.
Best on XAUUSD M5 (the strategy's native timeframe) with a low-spread ECN or RAW broker, since the 3-point slippage budget and the no-protective-stop design punish wide-spread execution. Minimum recommended balance: $100 for one 0.10-lot position, though the lack of a hard stop means risk-per-trade is uncapped, so size the account for several consecutive losing trades in a row. The 12-layer stack label in the header is partially aspirational: the visible source implements only SIGNAL, ENTRY, EXIT, and CONFIRM layers, with no regime, no-trade gate, drawdown cap, or risk-percent sizing actually present.
Strategy Logic
Pipsgrowth EX18093 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218093
Version: 2.00
BRIEF:
RSI scalping EA entering on RSI oversold/overbought cross with target-based exits and bars-against timeout exit logic. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
UpdateRSI()CheckExistingPosition()CheckEntrySignals()OpenBuyPosition()OpenSellPosition()ClosePosition()TryClose_EX18093()TryClosePartial_EX18093()TryModify_EX18093()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (12 total across 2 groups):
- [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_18093" // TradeComment - [=== Strategy Settings ===]
TimeFrame= 8 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Analysis - [=== Strategy Settings ===] RSI_Period = 14 //
RSIPeriod - [=== Strategy Settings ===] RSI_Applied_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) //
RSIApplied Price - [=== Strategy Settings ===] RSI_Overbought = 49 //
RSIOverbought Level - [=== Strategy Settings ===] RSI_Oversold = 46 //
RSIOversold Level - [=== Strategy Settings ===] RSI_Target_Buy = 85 //
RSITarget for Buy Exit - [=== Strategy Settings ===] RSI_Target_Sell = 35 //
RSITarget for Sell Exit - [=== Strategy Settings ===]
BarsToWait= 10 // Bars to wait whenRSIgoes against position - [=== Strategy Settings ===]
LotSize=0.1// Lot Size - [=== Strategy Settings ===]
MagicNumber=22218093// Magic Number - [=== Strategy Settings ===] Slippage = 3 // Slippage in points
// Pipsgrowth EX18093 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// RSI scalping EA entering on RSI oversold/overbought cross with target-based exits and bars-against timeout exit logic. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
ON_INIT:
Create indicator handles: standard set
Initialize state variables
Detect broker GMT offset
ON_TICK:
1. Refresh indicator buffers (closed-bar shift=1)
2. Manage existing positions:
- Break-even check
- ATR trailing stop
- Profit lock ratchet
- Time-based exit
- Opposite-signal exit
3. If new bar:
a. ClassifyRegime() — ADX/ATR/BB regime detection
b. NoTradeGate() checks:
- Market open + session filter
- Spread limit
- Cooldown after loss
- Consecutive loss limit
- Kill switch
- Max drawdown
- Max concurrent positions
- Daily/weekly loss limits
c. GenerateSignal() — strategy-specific entry logic
d. CheckConfirm() — HTF alignment + R:R + ADX minimum
e. Calculate position size from risk %
f. Execute with retry logic
g. Mark bar to prevent duplicates
ON_TESTER:
Custom fitness = weighted(RecoveryFactor, ROI, ProfitFactor, TradeCount, Sharpe, Drawdown)Optimization Profile
How to Install This EA on MT5
- 1Download the .mq5 file using the button above
- 2Open MetaTrader 5 on your computer
- 3Click File → Open Data Folder in the top menu
- 4Navigate to MQL5 → Experts and paste the .mq5 file there
- 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
- 6Drag the EA onto an H4 or Daily chart for best results
- 7Configure EMA periods, ADX threshold, and lot size in the dialog
- 8Enable Allow Algo Trading and click OK
EA Parameters
| Parameter | Default | Description |
|---|---|---|
| InpTradeComment | "Psgrowth.com Expert_18093" | Trade Comment |
| TimeFrame | 8 | Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Analysis |
| RSI_Period | 14 | RSI Period |
| RSI_Applied_Price | 1 | Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // RSI Applied Price |
| RSI_Overbought | 49 | RSI Overbought Level |
| RSI_Oversold | 46 | RSI Oversold Level |
| RSI_Target_Buy | 85 | RSI Target for Buy Exit |
| RSI_Target_Sell | 35 | RSI Target for Sell Exit |
| BarsToWait | 10 | Bars to wait when RSI goes against position |
| LotSize | 0.1 | Lot Size |
| MagicNumber | 22218093 | Magic Number |
| Slippage | 3 | Slippage in points |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18093 main — RSI scalping with target exits, full 12-layer stack."
#include <Trade\Trade.mqh>
//--- Input parameters
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;
case 4: return PERIOD_M30;
case 5: return PERIOD_H1;
case 6: return PERIOD_H4;
case 7: return PERIOD_D1;
default: return PERIOD_H1;
}
}
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;
case 2: return PRICE_OPEN;
case 3: return PRICE_HIGH;
case 4: return PRICE_LOW;
case 5: return PRICE_MEDIAN;
case 6: return PRICE_TYPICAL;
case 7: return PRICE_WEIGHTED;
default: return PRICE_CLOSE;
}
}
ENUM_TIMEFRAMES g_TimeFrame = PERIOD_H1;
ENUM_APPLIED_PRICE g_RSI_Applied_Price = PRICE_CLOSE;
input group "=== Identity ==="
input string InpTradeComment = "Psgrowth.com Expert_18093"; // Trade Comment
ENUM_TIMEFRAMES MapTimeframeInt(int tf)
{
switch(tf)
{
case 1: return PERIOD_M1;
case 2: return PERIOD_M5;
case 3: return PERIOD_M15;
case 4: return PERIOD_M30;
case 5: return PERIOD_H1;
case 6: return PERIOD_H4;
case 7: return PERIOD_D1;
default: return PERIOD_H1;
}
}
ENUM_APPLIED_PRICE MapAppliedPriceInt(int ap)
{
switch(ap)
{
case 1: return PRICE_CLOSE;Full source code available on download
Educational purposes only. Do NOT use with real money. Test on demo accounts only.
Clear Warning: Educational Purposes Only
Clear Warning: This Expert Advisor is for educational and testing purposes only. Do NOT use it with real money. Test only on demo accounts. Trading with real money involves substantial risk of capital loss. This does not constitute investment advice.
Recommended Brokers for This EA
These EAs run on MT5 — use a regulated broker with fast execution and tight spreads
Markets.com
Exness
IC Markets
Similar Expert Advisors
View All Expert AdvisorsMore Trend Following strategy EAs from our library
Pipsgrowth EX16080 Trend
Pipsgrowth.com EX16080 EURUSDTrendFollower — triple-EMA H4 trend follower, full 12-layer stack.
Pipsgrowth EX16081 Trend
Pipsgrowth.com EX16081 GoldTrendEA — XAUUSD H4 EMA cross with Fib targets, full 12-layer stack.
Pipsgrowth EX16033 Trend
Pipsgrowth.com EX16033 EA_Price_Action — price-action grid scalper, full 12-layer stack.
Community
Educational purposes only. Do NOT use with real money. Test on demo accounts only.