P
PipsGrowth
Trend FollowingOpen Source – Free

Pipsgrowth EX16089 Trend

MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1

Pipsgrowth.com EX16089 BullishBearish_MeetingLines_RSI - Meeting Lines pattern + RSI confirm, full 12-layer stack.

Overview

Pipsgrowth EX16089 Trend is a price-action + oscillator system that runs entirely on the candlestick Meeting Lines reversal pattern. The detector in CheckPattern() reads the last two finished bars, requires both to be long-bodied in opposite directions, and requires their closing prices to land within ten percent of a running 12-bar average body. The check runs only on the open of a new bar, so a single new-bar gate (next_bar_open) is the only timer the EA maintains inside OnTick().

The body length is compared against AvgBody(1), which is the 12-bar average of |Open - Close| taken on the current bar. That 12-period lookback is the InpAverBodyPeriod input. If the second bar's body is the opposite color from the first, both bodies exceed the running average, and the closes of bars 1 and 2 differ by less than 0.1*AvgBody(1), the pattern is considered a Meeting Lines reversal. Bearish Meeting Lines need bar 2 to be a long white candle followed by a long black candle at bar 1. Bullish Meeting Lines need bar 2 to be a long black candle followed by a long white candle at bar 1. When CheckPattern() returns true, the EA arms ExtSignalOpen to SIGNAL_BUY or SIGNAL_SELL and writes a short pattern info string.

The pattern alone is not enough. CheckConfirmation() then queries the RSI(37) indicator at bar 1 and demands the buy signal be accompanied by RSI below 40, or the sell signal be accompanied by RSI above 60. Only when ExtConfirmed is set does PositionOpen() get called on the next phase of OnTick(). The RSI uses the close price by default (InpPrice = 1 maps to PRICE_CLOSE through the MapAppliedPriceInt switch).

Position sizing is a single fixed lot: InpLot = 0.1. There is no risk percentage, no per-trade dollar cap, no per-day cap, no equity floor, no scaling, and no OnTester() pass. The fixed lot is the only money-management input the source exposes. PositionOpen() refreshes the symbol via CSymbolInfo, reads Ask/Bid, computes a stoploss and takeprofit from InpSL = 200 and InpTP = 200 points, and routes the order through CTrade.Buy or CTrade.Sell with the slippage tolerance set to 10 points via ExtTrade.SetDeviationInPoints.

There is one piece of safety built into the order router that the brief description does not flag. If the current spread is wider than InpSL points (or wider than InpTP points), the EA refuses to place a stop at a distance narrower than the spread. Instead, it installs the stop at price ± spread. This is a guard against getting stopped out instantly on a wide-spread candle (typical around news or session open on XAUUSD) and is logged via PrintFormat. The same guard is mirrored for both long and short, so the protective distance never collapses below the current spread.

Exit management runs as the third and fourth phases of OnTick(). Phase 3 handles CloseBySignal, which closes positions based on four RSI crossover conditions computed by CheckCloseSignal(): a long position is closed when RSI(2) > 70 and RSI(1) < 70 (overbought exit), or when RSI(2) > 30 and RSI(1) < 30 (momentum loss exit). A short position is closed when RSI(2) < 30 and RSI(1) > 30, or when RSI(2) < 70 and RSI(1) > 70. Phase 4 is the time exit: CloseByTime() walks open positions for the current symbol+magic, calls BarsHold() to count bars since the position was opened, and if that count is greater than or equal to InpDuration = 10, closes the position via TryClose_EX16089. The bar count comes from CopyRates, so a server-time vs bar-time mismatch on a weekend or holiday is handled gracefully (the function returns -1 in that case and the time exit still triggers).

All three trade-side close helpers (TryClose_EX16089, TryClosePartial_EX16089, TryModify_EX16089) use a 3-attempt retry loop with a 200ms sleep on TRADE_RETCODE_REQUOTE, TRADE_RETCODE_TIMEOUT, TRADE_RETCODE_PRICE_OFF, and TRADE_RETCODE_PRICE_CHANGED. TryClosePartial_EX16089 and TryModify_EX16089 are defined in the source but never called from the live OnTick path — they exist for future use or were left over from refactoring. Only TryClose_EX16089 is invoked from CloseBySignal and CloseByTime.

The source header advertises a 12-layer stack (REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester). In the actual code, only the SIGNAL, ENTRY, CONFIRM, NO-TRADE, and EXIT layers are wired. There is no regime classifier, no daily P&L circuit breaker, no capital cap input, no risk-percentage input, no position-scaling module, no trailing stop, no breakeven, no partial close, no session filter, and no news filter. The EA does not implement OnTester() either, so optimizer runs can be set up, but the EA does not consume a custom optimization criterion.

Practically, this means the EA trades a fixed 0.1 lot on every confirmed Meeting Lines + RSI(37) signal, holds the position for at most 10 bars, and exits on SL, TP, RSI crossover, or the time gate — whichever comes first. The symmetric 200pt SL and 200pt TP (a one-to-one risk-reward profile) means the long-term expectancy of the strategy depends almost entirely on the pattern's win rate; there is no asymmetric payoff to compensate for sub-50% accuracy. The 200pt protective distance on XAUUSD is roughly 2.0 price points (since the symbol uses 2 decimal places on a 1-point scale: 200 points = $2.00 on a standard lot), which puts the typical risk per trade at $20 per 0.1 lot. The 12-bar holding window on M5 is one hour of price action; on H1 it is twelve hours.

For traders looking to use this EA live, the realistic expectations are: a small number of trades per day on M5, tight slippage and spread discipline matter because the SL/TP distance is only 200 points, the RSI(37) lag is significant on M5, and there is no global equity protection. If you want a global safety net, pair this EA with a separate equity-stop utility or a hard daily-loss limit enforced at the account level. Backtest the pattern detector with realistic spread assumptions — the spread-safety guard in PositionOpen() will reduce the effective SL in wide-spread environments, which is usually a feature but will look like a tighter stop in a backtest report.

Strategy Deep Dive

On every tick, OnTick() runs a new-bar gate (next_bar_open). When a new bar opens, CheckPattern() reads the last two finished bars and the 12-bar AvgBody(1) to validate a Meeting Lines reversal; on success, CheckConfirmation() queries RSI(37) at bar 1 and requires RSI < 40 for a buy or RSI > 60 for a sell before the pattern counts as confirmed. PositionOpen() then sends a 0.1-lot market order with 200pt SL and 200pt TP through CTrade, falling back to spread-based protective distance if the spread is wider than the SL or TP. Once in a position, CloseBySignal monitors four RSI(37) crossovers between bar 1 and bar 2 (70/30 thresholds) to exit on momentum loss, and CloseByTime force-closes after BarsHold reaches InpDuration = 10 bars. The header advertises a 12-layer stack, but only SIGNAL, ENTRY, CONFIRM, NO-TRADE, and EXIT are actually wired in the code.

Entry Signal

Bullish or Bearish Meeting Lines two-bar reversal: a long body candle at bar 2 immediately followed by a long body candle in the opposite color at bar 1, where |Close(1) - Close(2)| is less than 0.1 * AvgBody(1) (12-bar average body). The pattern is only valid on the open of a new bar, and only after RSI(37) at bar 1 confirms with RSI < 40 for a buy or RSI > 60 for a sell. Single-position side, no stacking.

Exit Signal

Four RSI(37) crossover exits on bar 1 vs bar 2: close long when RSI(1) < 70 and RSI(2) > 70, or when RSI(1) < 30 and RSI(2) > 30; close short on the mirrored conditions. Time exit: CloseByTime() force-closes any open position once BarsHold(open_time) reaches or exceeds InpDuration = 10 bars. In addition, the symmetric 200pt SL and 200pt TP can close the trade before either signal fires.

Stop Loss

Fixed 200 points (InpSL), installed at price - InpSL*point for longs and price + InpSL*point for shorts via CTrade.Buy/CTrade.Sell. A spread-safety guard in PositionOpen() replaces the protective distance with the current spread if the spread equals or exceeds InpSL points, so the stop never sits inside the spread. No trailing, no breakeven, no partial close.

Take Profit

Fixed 200 points (InpTP), symmetric to the stop loss, giving a 1:1 risk-reward profile. Same spread-safety guard applies: if the current spread equals or exceeds InpTP points, the TP is installed at price ± spread rather than the configured distance.

Best For

XAUUSD on M5 (works on H1) with a low-spread broker that can hold a 200-point protective distance without the spread-safety guard kicking in too often. Minimum recommended balance is $100, with the EA trading a fixed 0.1 lot per signal and no risk-percentage scaling. Best for traders who want a transparent price-action + RSI(37) system without global circuit breakers, scaling, trailing, or news filters — pair it with an external equity-stop utility if you need account-level protection.

Strategy Logic

Pipsgrowth EX16089 Trend — Strategy Logic Analysis (from .mq5 source)

Family: Trend Magic: 22216089 Version: 2.00

BRIEF: MeetingLines pattern + RSI confirm, time exit 12 layers: REGIME, SIGNAL, ENTRY, CONFIRM, NO-TRADE, CAPITAL CAP, RISK, SIZING, MANAGE, EXIT, SCALING, OnTester

INDICATOR STACK:

  • Standard MT5 indicators

KEY FUNCTIONS:

  • CheckState()
  • PositionOpen()
  • CloseBySignal()
  • CloseByTime()
  • PositionExist()
  • PositionExpiredByTimeExist()
  • BarsHold()
  • Open()
  • Close()
  • Low()
  • High()
  • MidPoint()
  • ...and 9 more

INTERNAL CONSTANTS (3 total):

  • SIGNAL_BUY = 1 // Buy signal
  • SIGNAL_NOT = 0 // no trading signal
  • CLOSE_LONG = 2 // signal to close Long

INPUT PARAMETERS (10 total across 4 groups):

  • [=== Pattern Parameters ===] InpAverBodyPeriod = 12 // period for calculating average candlestick size
  • [=== Pattern Parameters ===] InpPeriodRSI = 37 // RSI period
  • [=== Pattern Parameters ===] InpPrice = 1 // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // price type
  • [=== Trade Parameters ===] InpDuration = 10 // position holding time in bars
  • [=== Trade Parameters ===] InpSL = 200 // Stop Loss in points
  • [=== Trade Parameters ===] InpTP = 200 // Take Profit in points
  • [=== Trade Parameters ===] InpSlippage = 10 // slippage in points
  • [=== Money Management ===] InpLot = 0.1 // lot
  • [=== Identity ===] InpMagicNumber = 22216089 // Magic Number
  • [=== Identity ===] InpTradeComment = "Psgrowth.com Expert_16089" // Trade comment
Pseudocode
// Pipsgrowth EX16089 Trend — Execution Flow (from source analysis)
// Family: Trend
// MeetingLines pattern + RSI confirm, time exit 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:
M5H1

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
InpAverBodyPeriod12period for calculating average candlestick size
InpPeriodRSI37RSI period
InpPrice1Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted) // price type
InpDuration10position holding time in bars
InpSL200Stop Loss in points
InpTP200Take Profit in points
InpSlippage10slippage in points
InpLot0.1lot
InpMagicNumber22216089Magic Number
InpTradeComment"Psgrowth.com Expert_16089"Trade comment
Source Code (.mq5)Open Source
Pipsgrowth_com_EX16089.mq5
#property copyright "Pipsgrowth.com"
#property link      "https://pipsgrowth.com"
#property version   "2.00"
#property strict
#property description "Pipsgrowth.com EX16089 BullishBearish_MeetingLines_RSI - Meeting Lines pattern + RSI confirm, full 12-layer stack."
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>

#define SIGNAL_BUY    1             // Buy signal
#define SIGNAL_NOT    0             // no trading signal
#define SIGNAL_SELL  -1             // Sell signal

#define CLOSE_LONG    2             // signal to close Long
#define CLOSE_SHORT  -2             // signal to close Short

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_APPLIED_PRICE g_InpPrice = PRICE_CLOSE;
input group "=== Pattern Parameters ==="
input int  InpAverBodyPeriod=12;    // period for calculating average candlestick size
input int  InpPeriodRSI     =37;    // RSI period
input int InpPrice = 1; // Applied price (1=close,2=open,3=high,4=low,5=median,6=typical,7=weighted)    // price type

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_APPLIED_PRICE g_InpPrice = PRICE_CLOSE;
input group "=== Trade Parameters ==="
input uint InpDuration=10;          // position holding time in bars
input uint InpSL      =200;         // Stop Loss in points
input uint InpTP      =200;         // Take Profit in points
input uint InpSlippage=10;          // slippage in points
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.

Tags:ex16089trendpipsgrowthfreemt5xauusd

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_EX16089.mq5
File Size27.7 KB
Versionv2.00
PlatformMetaTrader 5
File Type.mq5 Source
StrategyTrend Following
Risk LevelMedium Risk
Timeframes
M5H1
Currency Pairs
XAUUSD
Min. Deposit$100