Pipsgrowth EX18100 TrendFollow
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX18100 RSIScalping — RSI overbought/oversold scalping with target exits, full 12-layer stack.
Overview
EX18100 is a single-indicator reversion EA that builds every decision around one oscillator — a 14-period RSI — and a deliberately asymmetric threshold architecture. There is no multi-confirmation stack, no regime classifier, no ATR filter, and no trend overlay: the EA reads RSI on a closed bar, compares it against extreme oversold and overbought zones, and either opens a position or walks away until the next bar. The name on the slug says TrendFollow and the source header talks about a 12-layer stack, but the actual code in OnInit, OnTick, UpdateRSI, CheckEntrySignals, and CheckExistingPosition is a clean four-step pipeline: read the oscillator, decide, execute, manage. Everything else mentioned in the header block is aspiration, not implementation.
The only indicator handle created in OnInit is rsi_handle = iRSI(_Symbol, g_TimeFrame, RSI_Period, g_RSI_Applied_Price) with RSI_Period=14, RSI_Applied_Price=1 mapping to PRICE_CLOSE, and g_TimeFrame derived from the integer input TimeFrame via the MapTimeframeInt switch (1=M1, 2=M5, 3=M15, 4=M30, 5=H1, 6=H4, 7=D1, default 7→D1). UpdateRSI then copies three values into the rsi_buffer array with ArraySetAsSeries at true, populating rsi_two_bars_ago (index 2), rsi_prev (index 1), and rsi_current (index 0). The crossover test in CheckEntrySignals uses bar-2 against bar-1, not bar-1 against bar-0 — a deliberate choice that means the entry decision is locked in once bar-1 closes, and the still-forming current bar cannot flip the signal. That is the EA's only anti-repaint guard.
The entry thresholds are pushed to extremes: RSI_Oversold=10 and RSI_Overbought=77. A long fires when rsi_two_bars_ago ≤ 10 AND rsi_prev > 10, which means RSI had to be sitting in deep oversold two bars ago and has now lifted off the floor by the close of the previous bar. A short fires on the mirror condition: rsi_two_bars_ago ≥ 77 AND rsi_prev < 77. These are not mean-reversion signals to the midline — they are exhaustion signals at the tail. With RSI_Overbought set to 77 rather than the textbook 70, the EA is filtering for the kind of blow-off move that has historically marked local tops in trending gold, and RSI_Oversold=10 catches only the deepest capitulation wicks. The trade frequency at default settings is therefore low — possibly a handful of signals per week on XAUUSD M15, fewer on D1.
The exit logic in CheckExistingPosition has two paths. Path one is the target hit. For a long, the position closes when rsi_current ≥ RSI_Target_Buy=27; for a short, when rsi_current ≤ RSI_Target_Sell=43. Note the asymmetry: the long target sits 17 RSI points above the entry trigger (10→27), while the short target sits 34 points below (77→43). In practice that means shorts close roughly twice as far away from the trigger as longs do in RSI terms, but RSI is bounded, so the buy side frequently closes well before price has retraced to the entry candle. Path two is the bars-against timeout. While a long is open, if rsi_current < RSI_Oversold (10), the EA starts an integer counter at 1, increments it by 1 each bar the condition holds, and closes the position once bars_against_count ≥ BarsToWait=14. The moment RSI climbs back above 10 the counter resets to zero — the EA does not punish temporary dips, only sustained ones. The short path mirrors this against RSI_Overbought (77). BarsToWait=14 is a long lookback; it gives the trade room to breathe through a 14-bar shake-out before the EA admits the thesis was wrong.
The position management is intentionally minimal. The EA does not place a stop-loss or take-profit at open — both trade.Buy and trade.Sell pass 0,0 as SL and TP. There is no trailing stop, no break-even function, no partial close, no pyramiding, and no hedge. The single-position flag (position_open bool) is the only sizing gate. LotSize=0.1 is hardcoded as a fixed lot input with no risk% calculation, no margin check beyond what CTrade does internally, and no scaling across symbols. The CTrade object is configured with SetExpertMagicNumber(22218100), SetDeviationInPoints(Slippage=3), and SetTypeFilling(ORDER_FILLING_FOK) — FOK is unusual; most modern EAs use the auto-fill policy or IOC. FOK means the broker must fill the entire order immediately or reject; for gold and majors on a fast ECN this is fine, but on a market-execution broker that requotes, every entry will fail outright. There are three retry helpers — TryClose_EX18100, TryClosePartial_EX18100, TryModify_EX18100 — but only TryClose_EX18100 is actually wired into the live code path; the other two are dead code that no function calls.
The OnTick loop is bar-paced, not tick-paced. It first checks that Bars(_Symbol, g_TimeFrame) ≥ RSI_Period + 2 (a sanity guard so the iRSI buffer has enough data), then reads the current bar time and bails out if it matches last_bar_time. Only on a new bar does it call UpdateRSI, CheckExistingPosition, and then — if no position is open — CheckEntrySignals. The TRACE prints in the source are debug leftovers and do not affect execution. The source also contains four duplicated copies of MapTimeframeInt and four of MapAppliedPriceInt — an auto-template artifact from the EA generator, harmless because the MQL5 compiler absorbs the duplicates and the runtime behaviour is identical to having just one copy. The first occurrence wins for initialization; the later ones are inert.
What the EA does not do is worth being explicit about. There is no InpMaxDDPct drawdown kill switch, no MinEquityPercent equity floor, no MaxConsecLosses cooldown, no MaxDailyLossPercent, no news filter, no session filter (it trades whenever the market is open, including the Asian overnight where gold liquidity thins out), no spread cap (so a 50-pip gold spread during a rollover can still trigger an entry), no HTF bias, no scaling, no breakeven, no partial close, no OnTester fitness function, no chart panel. Every defensive concept the parent family typically inherits has been stripped out, leaving a bare-bones oscillator reversal system.
In backtesting, the expected profile is a low-trade-count equity curve with a modest win rate, occasional larger wins when a deep oversold/overbought reading reverses cleanly to the target, and a long tail of bars-against timeouts on trades that never quite get there. The asymmetric target zones mean that when the EA does catch a reversal, the short side tends to give a better reward-to-risk in RSI terms, but in price terms that depends entirely on where gold is ranging. The two-bar-ago vs previous-bar crossover logic means a trader watching the chart in real time can see the signal one bar before the EA acts, which is useful for manual intervention but also means news-driven spikes that fail to form a closed bar above the threshold do not trigger entries. Setting RSI_Overbought lower (e.g., 70) and RSI_Oversold higher (e.g., 30) would make the EA more active at the cost of noisier signals; tightening RSI_Target_Buy down to 20 would lock in smaller but more frequent wins. The current defaults are tuned for a patient operator who wants a few high-conviction reversion trades a week, not a high-frequency scalper.
Strategy Deep Dive
Pulls a single iRSI(14) into a three-slot buffer on every new bar and only acts on closed-bar values, then runs the signal layer in CheckEntrySignals: a buy if bar-2 RSI was at or below RSI_Oversold=10 and bar-1 RSI has crossed above it, a sell if bar-2 RSI was at or above RSI_Overbought=77 and bar-1 RSI has fallen back below. While a position is open, CheckExistingPosition reads current-bar RSI each new bar to compare against RSI_Target_Buy=27 (long exit) or RSI_Target_Sell=43 (short exit), and uses a 14-bar bars-against counter — reset the moment RSI re-enters the friendly zone — to bail out if RSI stays on the wrong side of the threshold. Order execution is a fixed LotSize=0.1 via CTrade set to FOK filling with 3-point slippage, and exits always route through TryClose_EX18100, a 3-attempt retry helper that handles requotes, timeouts, and price-changed errors. The strategy carries no regime classifier, no news filter, no session filter, no spread cap, no equity guard, no trailing stop, no partial close, and no OnTester fitness function — the entire risk story is the asymmetric threshold architecture and the bars-against timer.
A long entry fires when the 14-period RSI on close shows rsi_two_bars_ago ≤ 10 (extreme oversold) AND rsi_prev > 10 (crossed back up). A short entry fires on the mirror: rsi_two_bars_ago ≥ 77 AND rsi_prev < 77. Because the test uses bar-2 vs bar-1, signals cannot repaint on the still-forming current bar.
For a long position, the EA exits when current-bar RSI reaches RSI_Target_Buy=27 (a 17-point target zone from the 10 trigger), or invokes a 14-bar bars-against counter that closes the trade if RSI stays below oversold (10) for 14 consecutive closed bars. The short path mirrors against overbought=77 with target=43 and the same 14-bar timeout. The bars-against counter resets to zero the moment RSI re-enters the friendly zone.
No initial stop-loss is placed at order time — both trade.Buy and trade.Sell pass 0,0 brackets. The only protective mechanism is the 14-bar bars-against counter; positions that fail to recover within that window are force-closed on the next eligible bar. There is no trailing stop, no break-even, and no equity-floor kill switch.
No fixed take-profit distance — exits happen at RSI-target levels rather than price levels: long closes at RSI_Target_Buy=27, short at RSI_Target_Sell=43. The asymmetric zones give shorts a 34-RSI-point target window vs 17 for longs, so the long side tends to close earlier after the entry trigger in oscillator terms.
Minimum recommended balance: $100 at the default 0.1-lot position size. The default TimeFrame input is 7 (D1), but the bar-paced loop works cleanly from M5 through H1; M15 and M30 are the typical settings for visible swings. Best paired with a low-spread XAUUSD or major-FX feed on an ECN/RAW account — FOK filling requires the broker to honor immediate fills or reject cleanly, so market-execution brokers that requote heavily will degrade signal quality. Suitable for traders who accept the reversion philosophy: most trades end as small timeouts, with a minority capturing a full reversion to the midline.
Strategy Logic
Pipsgrowth EX18100 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218100
Version: 2.00
BRIEF:
RSI scalping EA that buys when RSI crosses up from oversold and sells when RSI crosses down from overbought. Exits when RSI reaches target levels or has been against the position for N bars. 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_EX18100()TryClosePartial_EX18100()TryModify_EX18100()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (12 total across 3 groups):
- [=== Strategy ===]
TimeFrame= 7 //Timeframe(1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Analysis - [=== Strategy ===] RSI_Period = 14 //
RSIPeriod - [=== Strategy ===] RSI_Applied_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) //
RSIApplied Price - [=== Strategy ===] RSI_Overbought = 77 //
RSIOverbought Level - [=== Strategy ===] RSI_Oversold = 10 //
RSIOversold Level - [=== Strategy ===] RSI_Target_Buy = 27 //
RSITarget for Buy Exit - [=== Strategy ===] RSI_Target_Sell = 43 //
RSITarget for Sell Exit - [=== Strategy ===]
BarsToWait= 14 // Bars to wait whenRSIgoes against position - [=== Risk Management ===]
LotSize=0.1// Lot Size - [=== Identity ===]
MagicNumber=22218100// Magic Number - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_18100" // TradeComment - [=== Identity ===] Slippage = 3 // Slippage in points
// Pipsgrowth EX18100 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// RSI scalping EA that buys when RSI crosses up from oversold and sells when RSI crosses down from overbought. Exits when RSI reaches target levels or has been against the position for N bars. 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 |
|---|---|---|
| TimeFrame | 7 | 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 | 77 | RSI Overbought Level |
| RSI_Oversold | 10 | RSI Oversold Level |
| RSI_Target_Buy | 27 | RSI Target for Buy Exit |
| RSI_Target_Sell | 43 | RSI Target for Sell Exit |
| BarsToWait | 14 | Bars to wait when RSI goes against position |
| LotSize | 0.1 | Lot Size |
| MagicNumber | 22218100 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_18100" | Trade Comment |
| Slippage | 3 | Slippage in points |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18100 RSIScalping — RSI overbought/oversold 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 "=== Strategy ==="
input int TimeFrame = 7; // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Analysis
input int RSI_Period = 14; // RSI Period
input int RSI_Applied_Price = 1; // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // RSI Applied Price
input double RSI_Overbought = 77; // RSI Overbought Level
input double RSI_Oversold = 10; // RSI Oversold Level
input double RSI_Target_Buy = 27; // RSI Target for Buy Exit
input double RSI_Target_Sell = 43; // RSI Target for Sell Exit
input int BarsToWait = 14; // Bars to wait when RSI goes against position
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;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.