Pipsgrowth EX18095 TrendFollow
MT5 Expert Advisor (Open Source) · XAUUSD · M5
Pipsgrowth.com EX18095 main — RSI scalping with target exits, full 12-layer stack.
Overview
Pipsgrowth EX18095 is a single-handle RSI(14) momentum system that has been wired, somewhat confusingly, around inverted threshold labels. The input panel ships with two RSI gates that read, by name, as oversold/overbought: RSI_Overbought = 54 and RSI_Oversold = 73. Inside the source these names are misleading — the higher value (73) is actually the long-side entry trigger and the lower value (54) is the short-side entry trigger. The result is a strategy that buys when RSI pushes into overbought territory and sells when RSI dips into mild oversold territory, which is a continuation-of-momentum stance rather than a mean-reversion one. The signal logic lives in CheckEntrySignals() and reads exactly two closed bars per arm: a long fires when rsi_two_bars_ago <= 73 && rsi_prev > 73; a short fires when rsi_two_bars_ago >= 54 && rsi_prev < 54. The two-bars-ago gate is the only debounce in the entry path — a bar that grazes 73 without having closed a previous bar on the inside never triggers.
Position management is the second notable design choice. There is no price stop-loss and no take-profit attached at open. Both trade.Buy(LotSize, _Symbol, ask, 0, 0, InpTradeComment) and trade.Sell(LotSize, _Symbol, bid, 0, 0, ...) are called with zero brackets, so the broker records the position without any protective orders. The actual exit machinery lives in CheckExistingPosition() and is purely RSI-driven. For a long position, the function first watches for the adverse cross: when rsi_current < 73 on a closed bar, rsi_against_position flips true and bars_against_count increments. If RSI stays below 73 the next bar, the counter increments again; the moment it reaches BarsToWait (default 1) the position is force-closed via TryClose_EX18095(). Crucially, any bar where RSI returns to the friendly side (rsi_current >= 73 for longs, rsi_current <= 54 for shorts) zeroes the counter, so the timeout only triggers on a run of consecutive adverse bars — a single wobble is forgiven as long as the next bar recovers. The symmetric short branch uses rsi_current > 54 as the adverse cross.
Target exits ride momentum to the RSI extremes. A long closes when rsi_current >= RSI_Target_Buy = 87, a short closes when rsi_current <= RSI_Target_Sell = 33. The gap between entry threshold and target is intentionally wide: 14 RSI points on the long side from 73 to 87, and 21 points on the short side from 54 to 33. With BarsToWait = 1, a long that breaks above 73 but fails to push toward 87 within one bar of retracement will be cut, so the practical trade shape is a fast push to the extreme, or nothing. The ClosePosition() function resets position_open, position_ticket, rsi_against_position, and bars_against_count to their neutral values after a successful close.
Sizing is hard-coded as a single input (LotSize = 50), and on 100 oz XAUUSD contracts that is institutional scale — a $100 account cannot support even one such position. There is no balance-proportional scaling, no risk-percentage calculation, no margin pre-check, and no OnTester() equity-curve fitter. The lot stays at 50 forever unless the operator edits the input. For real-money testing on retail capital, LotSize needs to be scaled down to micro-lot territory (0.01-0.10) before the EA is attached to a chart. The CTrade wrapper is configured with SetDeviationInPoints(3) and SetTypeFilling(ORDER_FILLING_FOK), so fills are all-or-nothing on every order; that is worth keeping in mind when re-tuning LotSize to make sure the broker can fill the requested volume in one shot.
Filling and retry logic is the only thing in the EA with any redundancy. TryClose_EX18095() wraps trade.PositionClose() in a 3-attempt loop with 200 ms sleeps on the requote/timeout/price-off/price-changed retcodes, which is the only retry helper that actually fires. TryClosePartial_EX18095() and TryModify_EX18095() are present in the source but unreferenced — no partial close, no SL/TP modification is ever requested because no SL or TP is ever set. Indicator stack is minimal: a single iRSI(_Symbol, g_TimeFrame, RSI_Period, g_RSI_Applied_Price) handle with RSI_Applied_Price defaulting to PRICE_CLOSE, evaluated on every new bar of the configured timeframe.
Time frame selection is handled by the TimeFrame input (default 8), which is fed into MapTimeframeInt(). The switch recognises values 1-7 (M1, M5, M15, M30, H1, H4, D1) and falls through to PERIOD_H1 for any other value, so the as-shipped TimeFrame = 8 resolves to H1 at runtime. There is no HTF filter, no regime classifier, no session gate, no spread cap, and no news filter in the code. The source also contains two full copies of both MapTimeframeInt() and MapAppliedPriceInt() (one at lines 32-59, another at 64-91) — an auto-template artifact that the MQL5 compiler absorbs without complaint. For traders who want to deploy this EA on a real account, the most useful additions would be a price-based stop (the bars-against timeout is strict but cannot limit a single-bar gap), a position-sizing calculation tied to account equity, and a session filter that restricts entries to the London and New York hours when the asymmetric 73/54 thresholds are most likely to see clean momentum breakouts on XAUUSD. As shipped, the EA is a research instrument that demonstrates a specific asymmetric threshold idea; the rest of the safety net is left to the operator.
Strategy Deep Dive
Each new bar of the configured timeframe (H1 by default) OnTick() copies the last three RSI(14, close) values into rsi_buffer[0..2] via UpdateRSI(), then runs CheckExistingPosition() to manage the live trade and only invokes CheckEntrySignals() when position_open is false. The single-position gate is the position_open boolean — there is no position scan, no pyramid, and no hedging. CTrade is configured with magic 22218095, slippage 3 points, and ORDER_FILLING_FOK, and TryClose_EX18095 wraps the close with 3 attempts of 200 ms between retries on requote/timeout/price-off/price-changed retcodes; TryClosePartial_EX18095 and TryModify_EX18095 are compiled but unreferenced because no SL/TP is ever set and no partial close is ever requested. Indicator stack is a single iRSI handle — no HTF filter, no regime classifier, no session gate, no spread cap, no news filter, no drawdown breaker. The TimeFrame=8 input falls through the 1-7 switch of MapTimeframeInt to PERIOD_H1, and the source contains two full copies of MapTimeframeInt and MapAppliedPriceInt (an auto-template artifact the MQL5 compiler absorbs without effect on runtime).
Long fires when iRSI(14, close) closes a bar at or below 73 and the next bar closes back above 73 (rsi_two_bars_ago <= 73 && rsi_prev > 73). Short fires symmetrically when RSI closes a bar at or above 54 and the next bar closes back below 54. The CheckEntrySignals() debounce uses rsi_two_bars_ago so a single bar that touches 73 without a previous close below it does not trigger, and entries are only evaluated on closed bars of the configured timeframe (H1 by default because TimeFrame=8 falls through the MapTimeframeInt switch).
Two exit paths in CheckExistingPosition(). Path 1: target exit — a long closes when rsi_current >= RSI_Target_Buy=87, a short closes when rsi_current <= RSI_Target_Sell=33. Path 2: bars-against timeout — when RSI re-crosses against the entry threshold on a closed bar (long: rsi_current < 73, short: rsi_current > 54), bars_against_count increments; when it reaches BarsToWait (default 1) the position is force-closed via TryClose_EX18095(), and the counter resets to zero the moment RSI returns to the friendly side. There is no price-based exit at open — trade.Buy / trade.Sell are called with 0/0 SL/TP brackets.
No price stop is ever attached at open — trade.Buy and trade.Sell are called with 0/0 brackets, so the broker records the position with no SL. The only invalidation is the bars-against RSI timeout in CheckExistingPosition(), which force-closes the trade when BarsToWait (default 1) consecutive closed bars have RSI on the wrong side of the entry threshold. On the as-shipped LotSize=50 against a $100 account, broker margin stop-out is the only absolute price protection; the operator must reduce LotSize to retail scale before any live deployment.
Target exits are RSI-level only — long closes at RSI_Target_Buy=87, short closes at RSI_Target_Sell=33. The target is at the extreme of the RSI(14) range (87 on the long side from a 73 entry, 33 on the short side from a 54 entry) and the trade is closed the moment the running bar prints at or past the target on a closed-bar basis. There is no fixed-pip TP, no partial profit-taking, and no multi-R target — if RSI fails to reach the target and the bars-against counter fires first, the position is force-closed without a TP fill.
Best on XAUUSD M5-H1 (H1 is the runtime default because TimeFrame=8 falls through MapTimeframeInt to PERIOD_H1). The DB-listed $100 minimum deposit is meaningful only if the operator reduces LotSize from the as-shipped 50 to retail scale (0.01-0.10 per trade); at 50 lots on a 100 oz XAUUSD contract the EA will hit margin call on the first position, so a $1,000-$5,000 account with LotSize tuned to roughly 0.05-0.20 is the realistic operating window. The asymmetric 73 long / 54 short thresholds profile as a momentum-continuation idea, so the EA works best on clean, single-direction gold sessions; restrict live deployment to the London and New York hours when RSI swings cleanly between 54 and 87, and use a low-spread ECN broker to keep the FOK fills honest — there is no spread filter and no news filter in the code.
Strategy Logic
Pipsgrowth EX18095 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218095
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_EX18095()TryClosePartial_EX18095()TryModify_EX18095()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (12 total across 2 groups):
- [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_18095" // 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 = 54 //
RSIOverbought Level - [=== Strategy Settings ===] RSI_Oversold = 73 //
RSIOversold Level - [=== Strategy Settings ===] RSI_Target_Buy = 87 //
RSITarget for Buy Exit - [=== Strategy Settings ===] RSI_Target_Sell = 33 //
RSITarget for Sell Exit - [=== Strategy Settings ===]
BarsToWait= 1 // Bars to wait whenRSIgoes against position - [=== Strategy Settings ===]
LotSize= 50 // Lot Size - [=== Strategy Settings ===]
MagicNumber=22218095// Magic Number - [=== Strategy Settings ===] Slippage = 3 // Slippage in points
// Pipsgrowth EX18095 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_18095" | 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 | 54 | RSI Overbought Level |
| RSI_Oversold | 73 | RSI Oversold Level |
| RSI_Target_Buy | 87 | RSI Target for Buy Exit |
| RSI_Target_Sell | 33 | RSI Target for Sell Exit |
| BarsToWait | 1 | Bars to wait when RSI goes against position |
| LotSize | 50 | Lot Size |
| MagicNumber | 22218095 | 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 EX18095 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_18095"; // 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.