P
PipsGrowth
Trend FollowingOpen Source – Free

Pipsgrowth EX18096 TrendFollow

MT5 Expert Advisor (Open Source) · XAUUSD · M5

Pipsgrowth.com EX18096 RSIScalping — RSI overbought/oversold scalping with target exits, full 12-layer stack.

Overview

Pipsgrowth EX18096 is a single-indicator RSI EA that lives entirely in the upper half of the indicator's range, never touching classic oversold bounces or 30/70 cross logic. Both trigger thresholds sit at extreme highs: RSI_Overbought is set to 90, RSI_Oversold to 73, and the long entry is fired when RSI climbs out of the 73 zone while the short entry is fired when RSI tumbles out of the 90 zone. The asymmetry — buys at 73, sells at 90 — produces a high-zone regime where the EA is only ever responding to RSI movements between 48 and 90. Because both entry thresholds sit in overbought territory, every trade the EA opens is, in the technical sense, a momentum trade from an already-strong market, not a rebound from weakness.

The signal itself is a two-bar crossover gate. UpdateRSI pulls three RSI(14) values (rsi_buffer[0..2]) and CheckEntrySignals compares bar[2] against bar[1]. A long is opened when rsi_two_bars_ago was at or below 73 and the previous bar closed strictly above 73. A short is opened when rsi_two_bars_ago was at or above 90 and the previous bar closed strictly below 90. The middle bar (rsi_buffer[1]) is the one that matters for the trigger — the bar-two-ago value is just a filter that prevents the EA from firing on a single-bar spike or a flat line. The applied price defaults to PRICE_CLOSE (RSI_Applied_Price=1) and the RSI period is 14, both fully exposed as inputs.

Exit logic is the second half of the design. CheckExistingPosition runs once per closed bar and has two parallel arms. The long arm exits at rsi_current >= RSI_Target_Buy (88) when the position is not 'against', and increments a bars-against counter (capped at BarsToWait=6) when rsi_current drops below 73. The short arm mirrors this: exit at rsi_current <= RSI_Target_Sell (48) when the position is not 'against', and accumulate a bars-against counter when rsi_current pushes back above 90. The 'against' counter resets the moment RSI returns to the friendly side, so a single recovery bar is enough to clear a partial drawdown episode. There is no price stop and no take-profit bracket at order open — trade.Buy and trade.Sell are called with sl=0 and tp=0, so the broker's account stop-out is the only hard price-side backstop.

A single-position gate runs through the position_open boolean. When CheckEntrySignals fires and the EA is already flat, OpenBuyPosition or OpenSellPosition is invoked; when a position is open, the entry path is skipped entirely. There is no pyramiding, no scaling, no adding-to-winner logic. Order execution goes through CTrade with SetTypeFilling(ORDER_FILLING_FOK), a 3-point deviation cap, and three retry helpers (TryClose_EX18096, TryClosePartial_EX18096, TryModify_EX18096) that re-attempt on requote, timeout, price-off and price-changed for 3×200ms or 3×100ms linear backoff. In this build only TryClose_EX18096 is actually called, because the position never receives a stop or a limit in the first place. The two partial/modify helpers are dead code in the active path.

Sizing is fixed at LotSize=0.1 with no risk percent, no balance scaling and no cap. The only sizing-related input is the literal lot number. There is no margin check before send, no OrderCalcMargin pre-flight, and no reduction when equity sags — so the operator needs to size to balance before attaching. There is also no time-of-day filter, no news filter, no higher-timeframe confirmation, and no regime classifier. The source code is a pure single-pass scalper: one indicator, one trigger, one exit, one position. OnTester is not defined, so backtests will not produce a custom optimization fitness value — the platform's default metric applies.

The header block advertises XAUUSD and H1 as the canonical setup, with the comment 'works M5H1' suggesting the strategy is portable across intraday timeframes. The TimeFrame input is mapped through a local MapTimeframeInt switch (1→M1, 2→M5, 3→M15, 4→M30, 5→H1, 6→H4, 7→D1) and falls through to PERIOD_H1 for any value outside that range, including the default input value of 8. In other words, leaving TimeFrame at its default selects H1. The same switch is repeated four times in the source file along with MapAppliedPriceInt and the g_TimeFrame/g_RSI_Applied_Price global declarations — a code-smell artifact from the generator template. The MQL5 compiler absorbs the duplicates, the runtime behaviour is unaffected, and a reader can ignore the duplication when reasoning about the strategy.

The practical trading profile this implies is a 'RSI momentum' book on a gold account. The 73/90 zones are above 50, so the EA skips most of the price action; it is only active when momentum has already pushed RSI to extremes. Longs get in on a re-strengthening bounce off 73 and exit on a 15-point climb to 88. Shorts get in on a retreat from 90 and target a 42-point fall to 48. The longer descent target on the short side, combined with the bars-against 6-bar timeout, makes short trades structurally longer in duration than long ones. There is no OnTester scoring function, no regime guard, and no equity throttle, so the operator inherits responsibility for setting the magic number, sizing the lot to balance, and managing the account-level risk themselves. This is a build for traders who already understand RSI behaviour at extreme levels and want a lean, single-indicator tool that only fires in high-momentum conditions.

Strategy Deep Dive

OnTick waits for a fresh bar on the configured timeframe, then UpdateRSI pulls the latest three RSI(14) values into rsi_buffer and CheckExistingPosition evaluates the open position against the bars-against counter and the target thresholds. When the EA is flat, CheckEntrySignals compares rsi_two_bars_ago against rsi_prev: a long fires on a cross above 73, a short on a cross below 90, and OpenBuyPosition or OpenSellPosition routes the order through CTrade with FOK filling and a 3-point slippage cap. With no SL/TP brackets at send, the bars-against timeout and the RSI target exits are the entire position management stack, and the single-position boolean means re-entry is gated until the previous ticket has been closed.

Entry Signal

Long entries fire when the previous closed bar pushed RSI(14) strictly above 73 while the bar two bars ago was at or below 73 — a two-bar crossover that catches RSI re-strengthening from a high baseline. Short entries fire when the previous bar pushed RSI strictly below 90 while the bar two bars ago was at or above 90 — a downward crossover out of extreme overbought. The asymmetric 73/90 thresholds mean both entry directions sit inside the overbought half of the RSI range.

Exit Signal

Long positions close when the current bar's RSI reaches the buy target at 88, or after BarsToWait=6 consecutive closed bars where RSI has dropped below the 73 threshold. Short positions close when the current bar's RSI reaches the sell target at 48, or after 6 consecutive closed bars where RSI has pushed back above 90. The bars-against counter resets instantly the moment RSI returns to the friendly side, so a single recovery bar is enough to clear a partial adverse run.

Stop Loss

The EA sends orders with sl=0 and tp=0, so there is no per-trade stop-loss bracket at the broker. The only price-side protection is the broker's account stop-out plus the bars-against counter in CheckExistingPosition, which closes a long after 6 closed bars with RSI below 73 or a short after 6 closed bars with RSI above 90.

Take Profit

Longs take profit at RSI_Target_Buy=88 on the current bar, with the target sitting 15 RSI points above the 73 entry threshold. Shorts take profit at RSI_Target_Sell=48, a 42-point fall from the 90 entry threshold, which makes the short side structurally a longer-duration trade. There is no pip-based TP at order open; both targets are RSI-level exits evaluated bar by bar.

Best For

Designed for the XAUUSD H1 setup at a $100 minimum balance with fixed 0.1-lot sizing, and best suited to a low-spread ECN or RAW broker because the 73/90 zones fire frequently on gold's intraday momentum swings. The strategy is portable to other FX majors and to M5H1 timeframes per the header note, but the high-zone RSI logic only produces signals when the underlying instrument trends strongly, so range-bound days on lower-volatility pairs will produce few or no entries. Pair it with manual lot-size management and an external equity throttle, since the EA does not include its own drawdown breaker, regime filter, news filter, or risk-percent sizing.

Strategy Logic

Pipsgrowth EX18096 TrendFollow — Strategy Logic Analysis (from .mq5 source)

Family: TrendFollow Magic: 22218096 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 MT5 indicators

KEY FUNCTIONS:

  • UpdateRSI()
  • CheckExistingPosition()
  • CheckEntrySignals()
  • OpenBuyPosition()
  • OpenSellPosition()
  • ClosePosition()
  • TryClose_EX18096()
  • TryClosePartial_EX18096()
  • TryModify_EX18096()

INTERNAL CONSTANTS (0 total):

INPUT PARAMETERS (12 total across 3 groups):

  • [=== Strategy ===] TimeFrame = 8 // Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Analysis
  • [=== Strategy ===] RSI_Period = 14 // RSI Period
  • [=== Strategy ===] RSI_Applied_Price = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // RSI Applied Price
  • [=== Strategy ===] RSI_Overbought = 90 // RSI Overbought Level
  • [=== Strategy ===] RSI_Oversold = 73 // RSI Oversold Level
  • [=== Strategy ===] RSI_Target_Buy = 88 // RSI Target for Buy Exit
  • [=== Strategy ===] RSI_Target_Sell = 48 // RSI Target for Sell Exit
  • [=== Strategy ===] BarsToWait = 6 // Bars to wait when RSI goes against position
  • [=== Risk Management ===] LotSize = 0.1 // Lot Size
  • [=== Identity ===] MagicNumber = 22218096 // Magic Number
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_18096" // Trade Comment
  • [=== Identity ===] Slippage = 3 // Slippage in points
Pseudocode
// Pipsgrowth EX18096 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

Optimized Brokers:
ExnessIC Markets
Optimized Symbols:
XAUUSD
Optimized Timeframes:
M5

How to Install This EA on MT5

  1. 1Download the .mq5 file using the button above
  2. 2Open MetaTrader 5 on your computer
  3. 3Click File → Open Data Folder in the top menu
  4. 4Navigate to MQL5 → Experts and paste the .mq5 file there
  5. 5In MT5, right-click Expert Advisors in the Navigator panel → Refresh
  6. 6Drag the EA onto an H4 or Daily chart for best results
  7. 7Configure EMA periods, ADX threshold, and lot size in the dialog
  8. 8Enable Allow Algo Trading and click OK

EA Parameters

ParameterDefaultDescription
TimeFrame8Timeframe (1=M1,2=M5,3=M15,4=M30,5=H1,6=H4,7=D1) // Timeframe for Analysis
RSI_Period14RSI Period
RSI_Applied_Price1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // RSI Applied Price
RSI_Overbought90RSI Overbought Level
RSI_Oversold73RSI Oversold Level
RSI_Target_Buy88RSI Target for Buy Exit
RSI_Target_Sell48RSI Target for Sell Exit
BarsToWait6Bars to wait when RSI goes against position
LotSize0.1Lot Size
MagicNumber22218096Magic Number
InpTradeComment"Psgrowth.com Expert_18096"Trade Comment
Slippage3Slippage in points
Source Code (.mq5)Open Source
Pipsgrowth_com_EX18096.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX18096 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 = 8; // 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 = 90;        // RSI Overbought Level
input double              RSI_Oversold = 73;          // RSI Oversold Level
input double              RSI_Target_Buy = 88;         // RSI Target for Buy Exit
input double              RSI_Target_Sell = 48;        // RSI Target for Sell Exit
input int                 BarsToWait = 6;             // 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.

Tags:ex18096trendfollowpipsgrowthfreemt5xauusd

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

Community

Sign in to contributeSign In

Educational purposes only. Do NOT use with real money. Test on demo accounts only.

File NamePipsgrowth_com_EX18096.mq5
File Size14.3 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyTrend Following
Risk LevelMedium Risk
Timeframes
M5
Currency Pairs
XAUUSD
Min. Deposit$100