Pipsgrowth EX18102 TrendFollow
MT5 Expert Advisor (Open Source) · AUDUSD · M15, H1
Pipsgrowth.com EX18102 SimpleRSIReversalAUDUSD — RSI reversal in Asian session with panel, full 12-layer stack.
Overview
EX18102 is a single-indicator session-timed reversal EA. The strategy watches a 28-period Relative Strength Index on the M15 chart, looks for RSI(28) to cross the 30 (oversold) and 68 (overbought) thresholds, and treats those crossovers as buy and sell signals. The whole system is gated to the Asian session — 00:00 to 08:00 UTC — and any open position is force-closed as soon as the clock leaves that window.
The signal is a true reversal pattern, not a trend-following one. The long entry fires when the previous bar's RSI was above 30 and the current bar's RSI has dropped to or through 30. In other words, the EA buys into exhaustion: when momentum falls into deep oversold on the M15 chart, the EA enters long and waits for a mean reversion. The short entry mirrors it — RSI crosses above 68, the EA sells. Both thresholds sit slightly inside the conventional 30/70 band, which filters out a few of the marginal crossovers you would see at the textbook levels.
RSI computation lives in a single indicator handle, rsiHandle = iRSI(_Symbol, PERIOD_M15, RSIPeriod, PRICE_CLOSE). The EA reads the last three RSI values into a 3-slot buffer (rsiCurrent, rsiPrevious, rsiPrevious2) on every tick, then CheckRSICrossover() looks at the current-vs-previous bar to flag three boolean states: rsiCrossedOversold, rsiCrossedOverbought, and rsiCrossedExitLevel. Those flags feed both the entry logic and the on-chart panel.
The session filter is implemented in two places. IsAsianSession() returns true when timeStruct.hour >= 0 && timeStruct.hour < 8. When the tick falls outside that window, the EA either returns immediately (no new entries) or — if CloseOutsideSession is true — runs CloseAllTrades("Outside Asian session") to flatten any open position. There is also a sessionCloseAttempted boolean that prevents the close order from being issued more than once per non-Asian block. The same time-struct lookup drives GetCurrentSession(), which labels each hour as Asian, London (08:00-16:00 UTC), New York (13:00-21:00 UTC), or "Other" for the 21:00-00:00 gap. The two New York / London windows overlap at 13:00-16:00 UTC, but the EA's trade gating still depends only on the Asian block.
Position sizing is fixed, not risk-based. The input MaxLotSize = 0.2 is the literal volume written to trade.Buy(...) and trade.Sell(...). There is no AccountInfoDouble(ACCOUNT_BALANCE) * riskPercent / slDistance calculation anywhere in the source, and the lot size does not adapt to the SL distance when one is enabled. This is unusual for a PipsGrowth EA and is one of the most consequential design choices in the file — the dollar risk per trade is determined entirely by the broker's tick value, not by the EA.
SL and TP are both off by default (UseStopLoss = false, UseTakeProfit = false). When disabled, trade.Buy(MaxLotSize, _Symbol, currentAsk, 0, 0, ...) opens the position with zero brackets — the trade has no protective stop and no take profit at the broker. The two pip inputs StopLossPips = 5 and TakeProfitPips = 175 are still there in the parameter list, and the panel always displays them, but they are dormant unless you flip the boolean flags. A 5-pip stop on AUDUSD M15 is extremely tight — roughly the size of a single bar's range in active hours. A 175-pip target implies a 1:35 reward-to-risk structure that almost never plays out on a mean-reversion trade.
There are two real exit paths. The first is a time stop: if TimeCurrent() - positionOpenTime > MaxDuration * 3600 (340 hours by default — about 14 days), CloseAllTrades("Timeout") is called. The second is the RSI exit, gated by UseRSIExit = true and RSIExitLevel = 48. With the default 48, the EA closes a long when RSI crosses above 48 and closes a short when RSI crosses below 48. The level is set just below the 50 midline, which means longs exit on a return to neutral momentum, not on a full reversion to overbought. Shorts have to give back roughly the same distance to trigger.
Order execution goes through the standard CTrade wrapper. trade.SetDeviationInPoints(3) allows 3 points of slippage, trade.SetTypeFilling(ORDER_FILLING_IOC) requests Immediate-Or-Cancel filling, and trade.SetExpertMagicNumber(22218102) ties every order to this EA's magic. The single-position gate is the loop over PositionsTotal() that runs in OnTick — if any position exists on the symbol, no new entries are considered. There is no pyramiding, no scaling-in, and no re-entry logic.
The retry layer is a copy-paste of the standard PipsGrowth helper set: TryClose_EX18102(ulong ticket), TryClose_EX18102(string symbol), TryClosePartial_EX18102(ticket, volume), and TryModify_EX18102(ticket, sl, tp). Each loops three times with a 100-200 ms sleep between attempts, only retrying on TRADE_RETCODE_REQUOTE, TIMEOUT, PRICE_OFF, and PRICE_CHANGED. In the live execution path, only the string symbol variant of TryClose_EX18102 is actually called from CloseAllTrades() — the partial-close and modify helpers are dead code in this build.
The on-chart panel is the most visible feature of the EA. CreatePanel() builds a 200x200 black rectangle with a "RSI Reversal" title and seven data labels: RSI value, current position, spread in pips, session name, stop loss, take profit, and the most recent crossover state (None / Overbought / Oversold / Exit). UpdatePanel() rewrites the seven labels on every tick. The panel position is configurable via PanelX and PanelY (defaults 10 and 20 — top-left corner). Panel colors are also exposed as inputs (PanelBackground, PanelText).
Two non-obvious things show up if you read the source carefully. First, MaxSpread = 1000 is a default so loose it is effectively disabled — at AUDUSD's typical 0.5-2 pip spread, the filter is never the binding constraint. Second, CloseAllTrades() contains a reference to PositionGetInteger(POSITION_MAGIC) == 123456 — a leftover from the template generator. The result of that check (hasOurPositions) is never used afterwards, and all real closure uses the symbol-based path, so the wrong magic number is a no-op rather than a bug in the live behavior. But it is a sign the file came from a stock template without a final per-EA scrub.
The header block claims a "12-layer architecture" (REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester). In the actual code only SIGNAL, ENTRY, SESSION-FILTER (a narrow slice of NO-TRADE), and EXIT are real. There is no regime classifier, no higher-timeframe confirmation, no capital cap, no risk-percentage sizing, no scaling module, and no OnTester function. Treat the 12-layer claim as marketing copy, not an implementation contract.
What to expect in backtest: a low-frequency, session-restricted mean-reversion profile on AUDUSD M15. Win rate on a 5-pip-stop / 175-pip-target asymmetry is structurally going to be poor — the SL fires constantly during ranging hours and the TP almost never hits. The realistic edge has to come from the RSI-exit path (closing at 48 instead of waiting for the 175-pip TP) and from the Asian session filter (cutting exposure before the London break). If you run this on a long enough window, the equity curve tends to drift, not to climb, and the dominant cost is broker spread on the 5-pip stops. With UseStopLoss = true and a wider stop — say 25-40 pips on M15 — the profile looks different, but you are now trading the EA's exit discipline, not the EA's signal.
For a live setup, run this on an AUDUSD M15 chart on a low-spread ECN or RAW account, with UseStopLoss = true at a sensible distance for the pair (20-30 pips, not 5), UseRSIExit = true, and UseTakeProfit = false (let the RSI exit do the work). The 100 USD minimum deposit that the input block lists is only meaningful for the fixed 0.2-lot sizing — you need enough margin to absorb a single M15 reversal without a margin call. If you want to scale up, change MaxLotSize proportionally; the EA will not adapt it for you.
Strategy Deep Dive
On every tick, OnTick checks the Asian-session gate (00:00-08:00 UTC) and bails out (or, with CloseOutsideSession=true, force-closes any open position) if the clock is outside that window. Inside the window, it reads the last three iRSI(28) values into rsiCurrent, rsiPrevious, rsiPrevious2, and runs CheckRSICrossover() to set the three crossover flags. With no position open, an oversold cross (current <= 30 from above) fires a 0.2-lot Buy at the current ask with 0/0 SL/TP brackets; an overbought cross (current >= 68 from below) fires a Sell. With a position open, the EA either exits on the RSI-48 cross, hits the 340-hour time stop, or gets force-closed at the Asian session boundary. There is no regime classifier, no HTF filter, no risk-percentage sizing, no pyramiding, and no OnTester — the 12-layer claim in the header is marketing copy, not implemented code.
Long entry fires when the 28-period RSI crosses DOWN through 30 (the prior bar's RSI > 30 and the current bar's RSI <= 30) — a buy into deep oversold on the M15 chart. Short entry fires on the opposite: RSI crosses UP through 68 (prior < 68 and current >= 68). All entries are gated to the Asian session (00:00-08:00 UTC) and blocked when the symbol's spread exceeds MaxSpread.
Two exit paths. The first is a time stop — if the position has been open for more than MaxDuration * 3600 seconds (340 hours by default, ~14 days), CloseAllTrades("Timeout") is called. The second is the RSI exit — with UseRSIExit=true, a long closes when RSI crosses above 48 and a short closes when RSI crosses below 48. Positions are also force-closed when the clock leaves the Asian session if CloseOutsideSession is enabled.
Stop-loss is OFF by default. UseStopLoss=false means trade.Buy / trade.Sell are sent with sl=0, so the broker has no protective stop attached. Enabling it applies a fixed StopLossPips=5 distance from entry (extremely tight on AUDUSD M15). Use a wider value such as 20-30 pips if you choose to enable it.
Take-profit is OFF by default. UseTakeProfit=false means tp=0 is sent on order entry. The TakeProfitPips=175 input sits dormant. In practice, the EA exits on the RSI 48 cross (long: rsi crosses up through 48; short: rsi crosses down through 48) rather than waiting on a fixed pip target.
Best suited to AUDUSD on the M15 chart on a low-spread ECN or RAW broker, with a balance of at least $100 to absorb the fixed 0.2-lot sizing and enough margin for an M15 reversal without a margin call. Run with UseStopLoss=true at 20-30 pips (not 5), UseRSIExit=true, and UseTakeProfit=false, and trade the Asian session (00:00-08:00 UTC) — the EA will close any open position automatically at the session boundary.
Strategy Logic
Pipsgrowth EX18102 TrendFollow — Strategy Logic Analysis (from .mq5 source)
Family: TrendFollow
Magic: 22218102
Version: 2.00
BRIEF:
Simple RSI reversal EA targeting Asian session hours. Buys on oversold crossover and sells on overbought crossover with optional SL/TP and RSI-based exit. Includes on-chart info panel. 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
CreatePanel()CreateScoreLabel()UpdatePanel()IsAsianSession()GetCurrentSession()IsTradingAllowed()CheckRSICrossover()CloseAllTrades()TryClose_EX18102()TryClosePartial_EX18102()TryModify_EX18102()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (19 total across 3 groups):
- [=== Strategy ===] RSIPeriod = 28 //
RSIperiod - [=== Strategy ===]
OverboughtLevel= 68 // Overboughtlevel - [=== Strategy ===]
OversoldLevel= 30 // Oversoldlevel - [=== Strategy ===]
TakeProfitPips= 175 // Take profit in pips - [=== Strategy ===]
StopLossPips= 5 // Stop loss in pips - [=== Strategy ===]
MaxLotSize=0.2// Maximum lot size - [=== Strategy ===]
MaxSpread= 1000 // Maximum allowed spread in pips - [=== Strategy ===]
MaxDuration= 340 // Maximum trade duration in hours - [=== Strategy ===]
UseStopLoss=false// Use stop loss - [=== Strategy ===]
UseTakeProfit=false// Use take profit - [=== Strategy ===]
UseRSIExit=true// UseRSIfor exit - [=== Strategy ===] RSIExitLevel = 48 //
RSIlevelto exit (50 = neutral) - [=== Strategy ===]
CloseOutsideSession=true// Close trades outside Asian session - [=== Panel ===]
PanelBackground=clrBlack// Panel background color - [=== Panel ===]
PanelText=clrWhite// Panel text color - [=== Panel ===]
PanelX= 10 // Panel X position - [=== Panel ===]
PanelY= 20 // Panel Y position - [=== Identity ===]
InpMagicNumber=22218102// Magic Number - [=== Identity ===]
InpTradeComment= "Psgrowth.com Expert_18102" // TradeComment
// Pipsgrowth EX18102 TrendFollow — Execution Flow (from source analysis)
// Family: TrendFollow
// Simple RSI reversal EA targeting Asian session hours. Buys on oversold crossover and sells on overbought crossover with optional SL/TP and RSI-based exit. Includes on-chart info panel. 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 |
|---|---|---|
| RSIPeriod | 28 | RSI period |
| OverboughtLevel | 68 | Overbought level |
| OversoldLevel | 30 | Oversold level |
| TakeProfitPips | 175 | Take profit in pips |
| StopLossPips | 5 | Stop loss in pips |
| MaxLotSize | 0.2 | Maximum lot size |
| MaxSpread | 1000 | Maximum allowed spread in pips |
| MaxDuration | 340 | Maximum trade duration in hours |
| UseStopLoss | false | Use stop loss |
| UseTakeProfit | false | Use take profit |
| UseRSIExit | true | Use RSI for exit |
| RSIExitLevel | 48 | RSI level to exit (50 = neutral) |
| CloseOutsideSession | true | Close trades outside Asian session |
| PanelBackground | clrBlack | Panel background color |
| PanelText | clrWhite | Panel text color |
| PanelX | 10 | Panel X position |
| PanelY | 20 | Panel Y position |
| InpMagicNumber | 22218102 | Magic Number |
| InpTradeComment | "Psgrowth.com Expert_18102" | Trade Comment |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX18102 SimpleRSIReversalAUDUSD — RSI reversal in Asian session with panel, full 12-layer stack."
// Include trade class
#include <Trade\Trade.mqh>
// Input parameters
input group "=== Strategy ==="
input int RSIPeriod = 28; // RSI period
input double OverboughtLevel = 68; // Overbought level
input double OversoldLevel = 30; // Oversold level
input int TakeProfitPips = 175; // Take profit in pips
input int StopLossPips = 5; // Stop loss in pips
input double MaxLotSize = 0.2; // Maximum lot size
input int MaxSpread = 1000; // Maximum allowed spread in pips
input int MaxDuration = 340; // Maximum trade duration in hours
input bool UseStopLoss = false; // Use stop loss
input bool UseTakeProfit = false; // Use take profit
input bool UseRSIExit = true; // Use RSI for exit
input double RSIExitLevel = 48; // RSI level to exit (50 = neutral)
input bool CloseOutsideSession = true; // Close trades outside Asian session
input group "=== Panel ==="
input color PanelBackground = clrBlack; // Panel background color
input color PanelText = clrWhite; // Panel text color
input int PanelX = 10; // Panel X position
input int PanelY = 20; // Panel Y position
input group "=== Identity ==="
input int InpMagicNumber = 22218102; // Magic Number
input string InpTradeComment = "Psgrowth.com Expert_18102"; // Trade Comment
// Global variables
CTrade trade;
int rsiHandle;
bool isPositionOpen = false;
double positionOpenPrice = 0;
datetime positionOpenTime = 0;
ENUM_POSITION_TYPE lastPositionType = POSITION_TYPE_BUY;
bool sessionCloseAttempted = false; // Track if we've attempted to close positions for current session
// RSI crossover variables
double rsiCurrent = 0;
double rsiPrevious = 0;
double rsiPrevious2 = 0;
bool rsiCrossedOverbought = false;
bool rsiCrossedOversold = false;
bool rsiCrossedExitLevel = false;
// Panel objects
string panelName = "RSIPanel";
int panelWidth = 200;
int panelHeight = 200;
int labelHeight = 20;
int labelSpacing = 5;
// Session times (UTC)
const int AsianSessionStart = 0; // 00:00 UTC
const int AsianSessionEnd = 8; // 08:00 UTC
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.