Pipsgrowth EX16072 Trend
MT5 Expert Advisor (Open Source) · XAUUSD · M5, H1
Pipsgrowth.com EX16072 Ronz SLTP MT5 — auto SL/TP manager with lock-profit and trailing stop, full 12-layer stack.
Overview
Pipsgrowth EX16072 is a position-management utility — it does not place trades of its own. Its single job is to babysit positions that another EA or a manual trader has already opened on the account, then layer three protective systems on top of them: an initial stop-loss and take-profit installation pass, a one-shot profit lock that fires once the trade clears a profit threshold, and a continuously ratcheting trailing stop. Because nothing in the codebase generates an entry signal, no indicator is ever created — the source compiles with zero iMA/iRSI/iMACD/iATR handles. Every reading the EA does comes from PositionGetDouble, PositionGetInteger, and SymbolInfo* lookups on positions it finds in the terminal.
The first pass runs in AutoSLTP::SetInstantSLTP(), which iterates from the back of the position stack forward (PositionsTotal()-1 down to 0) so closing a ticket mid-loop does not disturb the remaining scan. Each ticket is filtered through chartMode: when ChartSymbolSelection is set to AllOpenOrder (the default) the EA touches every open position on the account; when it is set to CurrentChartSymbol the EA keeps only positions whose symbol matches the chart's Symbol(). Everything past the filter is split between two SL/TP modes selected by SLnTPMode.
In Server mode the EA pushes the SL and TP up to the broker. For a buy it sets SL = openPrice − (StopLoss + minstoplevel) * point and TP = openPrice + (TakeProfit + minstoplevel) * point; for a sell the sign on each is flipped. The minstoplevel term is the broker's SYMBOL_TRADE_STOPS_LEVEL added so the price never violates the minimum-distance rule. The mode is a three-state setter: if both SL and TP are zero on the position it installs both; if only TP is missing it installs TP while keeping the existing SL; if only SL is missing it installs SL while keeping the existing TP. TryModify_EX16072() wraps the call with up to three retries on requote/timeout. Client mode is the opposite philosophy: the EA deliberately does not send SL or TP to the server, but instead polls profit and loss in points (Poin) and triggers TryClose_EX16072() the moment Poin >= TakeProfit or Poin <= -StopLoss. This is the hidden / virtual SL&TP that some prop-firm setups and certain ECN brokers prefer. With inpEnableAlert enabled the EA pops an Alert() telling the user which ticket closed and whether it was a profit or loss close.
The second pass is the profit lock in AutoSLTP::LockProfit(). Once Poin >= LockProfitAfter (default 100 points in profit), the EA sets a fixed protective stop at openPrice + ProfitLock * point for a buy, or openPrice − ProfitLock * point for a sell — a 60-point break-even cushion by default. The function deliberately only fires when CurrentSL <= openPrice on a buy (or >= openPrice on a sell), so the lock can never move the stop backwards. The Print() warning when Targetpoint < Lockedpoint is a sanity check the developer left in: the lock target should always be further from entry than the lock distance, otherwise the lock arm never engages.
The third pass is the trailing stop in AutoSLTP::RZ_TrailingStop(). It only fires after LockProfitAfter + TrailingStop points of profit (the legacy version's gate), or right away if LockProfitAfter is set to 0. Four trailing methods are selectable through TrailingStopMethod. TS_CLASSIC keeps the stop exactly TrailingStop points behind price on every move. TS_STEP_DISTANCE keeps the stop TrailingStop − TrailingStep points behind, so the actual distance from price grows as TrailingStop is configured wider. TS_STEP_BY_STEP is the slow ratchet: it advances the stop by TrailingStep points every time price has moved TrailingStop further, never the whole distance in one tick. TS_NONE disables trailing entirely. Each method runs the same buy/sell split: buys raise the stop into profit, sells lower the stop into profit, and the new stop is only emitted through TryModify_EX16072() when it differs from the existing one (so the broker doesn't get spammed with no-op modifications).
A small but useful helper is OrderTest(), gated behind inpEnableTest and MQLInfoInteger(MQL_TESTER). When the strategy tester fires up with an empty account, this function opens a 0.01-lot EURUSD buy and a 0.01-lot GBPUSD sell so the rest of the SL/TP, lock and trailing code has live positions to chew on. In live trading OrderTest() is dormant — the EA is strictly a passive manager. OnTick() itself is thin: count positions, if there are any, hand off to SetInstantSLTP(). There is no timer, no OnTradeTransaction, no bar-event gate — the EA reacts purely to incoming ticks.
In practical terms, the broker profile that suits this EA is one that supports either the SYMBOL_TRADE_STOPS_LEVEL (so the math comes out to a real level) or has a hidden/virtual SL scheme. Because the EA adds minstoplevel to every stop it sets, brokers that require a wide minimum stop distance (gold on some venues, exotic FX pairs) are handled correctly. Slippage tolerance is the Slippage input (10 points default) passed into trade.SetDeviationInPoints(). For a trader who runs multiple EAs and needs every open position to carry the same protective envelope, dropping EX16072 on a single chart and leaving ChartSymbolSelection = AllOpenOrder means one chart sweep covers the entire account.
The risk of using EX16072 is the same risk that any protective-stop utility carries: it cannot save a strategy that loses money on the entries. It only formalises the stops and trails. If the upstream EA enters on weak signals and TakeProfit=550/StopLoss=350 produces a negative expected value, this utility will simply cut those losses at exactly the configured distance, with the additional friction of profit-lock and trailing occasionally exiting earlier than a static TP would. The recommended deployment is to leave the defaults until enough demo-trading history is in, then either widen StopLoss for more headroom, switch to TS_STEP_BY_STEP for a slower trail, or flip SLnTPMode to Client to keep stops off the broker's book.
Strategy Deep Dive
Every tick the OnTick handler calls CalculateInstantOrders() to count positions matching the magic 22216072, then SetInstantSLTP() runs three layered passes over each ticket. Pass one installs or completes the initial SL/TP using SetInstantSLTP()'s branch logic — Server mode pushes the levels to the broker via TryModify_EX16072 (which retries three times on requote/timeout), Client mode keeps the levels off the broker and uses TryClose_EX16072 when the profit/loss threshold is breached. Pass two runs LockProfit(): once Poin crosses LockProfitAfter (default 100 points), it installs a one-shot break-even stop at openPrice ± ProfitLock*point. Pass three fires RZ_TrailingStop(), which selects between four algorithms — TS_CLASSIC (raw ratchet), TS_STEP_DISTANCE (offset by TrailingStep), TS_STEP_BY_STEP (slow, TrailingStep per TrailingStop move), or TS_NONE — and only emits a modification when the new stop actually differs from the existing one. The OrderTest() helper, gated behind inpEnableTest and MQL_TESTER, opens a 0.01-lot EURUSD buy and GBPUSD sell when the strategy tester starts with an empty account so the rest of the management code has live positions to act on.
EX16072 does not generate entries. It is a pure position-management utility: on every tick it scans positions matching the magic 22216072 (or all open positions when ChartSymbolSelection = AllOpenOrder), then runs SL/TP installation, profit-lock, and trailing-stop passes over whatever tickets already exist on the account. Attach it to any chart that has open positions, or to a dedicated chart that the upstream EA is operating on, and it will start managing them on the next tick.
Two parallel exit paths: (1) take-profit is hit either at the broker in Server mode (TP = openPrice ± (TakeProfit + minstoplevel) * point) or locally in Client mode where TryClose_EX16072 fires when Poin >= TakeProfit, and (2) stop-loss behaves identically — broker-side modification in Server mode, client-side TryClose when Poin <= -StopLoss. After the profit-lock arms (default 100 points in profit), a one-shot LockProfit() call sets a break-even protective stop at openPrice ± ProfitLock*point. From that point on, RZ_TrailingStop() takes over using the selected method (CLASSIC / STEP_DISTANCE / STEP_BY_STEP / NONE) to ratchet the stop behind price.
Initial stop-loss is set in points (StopLoss = 350 default) measured from open price, with the broker's SYMBOL_TRADE_STOPS_LEVEL added before sending the modification so the resulting price clears the minimum-distance rule. In Server mode the SL is a real position property; in Client mode the SL is virtual and a TryClose_EX16072 triggers the exit. After the profit-lock arm fires, the SL migrates to openPrice + ProfitLock*point (60 points break-even by default), then RZ_TrailingStop ratchets it behind price using one of four algorithms.
Take-profit defaults to 550 points from open price, applied the same way as the stop — broker-side TP in Server mode (TP = openPrice + (TakeProfit + minstoplevel)*point for buys, mirrored for sells) or client-side virtual TP that closes the position via TryClose when Poin >= TakeProfit. The TP can also be entirely absent if TakeProfit is set to 0; in that case LockProfit and the trailing stop still operate on the trade.
Traders who already run one or more entry EAs (or place trades manually) and want a uniform protective envelope across every open position on the account. EX16072's default StopLoss=350 / TakeProfit=550 / LockProfitAfter=100 / ProfitLock=60 / TrailingStop=50 / TrailingStep=10 is built around XAUUSD-style volatility, so a low-spread broker on gold or FX majors is the natural home. Recommended starting balance: $100 (the EA's stated minDeposit) since the utility does not size positions — it only sets SL/TP/lock/trail on positions opened by other code. The Client (hidden) mode makes it suitable for prop-firm challenges that forbid visible server-side stops; the Server mode suits ECN accounts where visible stops are preferred.
Strategy Logic
Pipsgrowth EX16072 Trend — Strategy Logic Analysis (from .mq5 source)
Family: Trend
Magic: 22216072
Version: 2.00
BRIEF:
Auto SL/TP manager that applies stop-loss and take-profit to open positions with lock-profit and trailing-stop features. Supports server-side or hidden (client) SL/TP and multiple trailing methods
INDICATOR STACK:
- Standard
MT5indicators
KEY FUNCTIONS:
TryClose_EX16072()TryClosePartial_EX16072()TryModify_EX16072()
INTERNAL CONSTANTS (0 total):
INPUT PARAMETERS (13 total across 1 groups):
- []
InpMagicNumber=22216072// Magic number - []
TakeProfit= 550 // Take Profit - []
StopLoss= 350 // Stop Loss - [] SLnTPMode = Server // SL & TP Mode
- []
LockProfitEnable=LP_ENABLE// Enable/Disable Profit Lock - []
LockProfitAfter= 100 // Target point to Lock Profit - []
ProfitLock= 60 // Profit To Lock - []
TrailingStopMethod=TS_CLASSIC// Trailing Method - []
TrailingStop= 50 // Trailing Stop - []
TrailingStep= 10 // Trailing Stop Step - [] Slippage = 10 // Slippage
- []
ChartSymbolSelection=AllOpenOrder// input boolinpEnableAlert=false;//EnableAlert - []
inpEnableTest=false// Enable Test on Strategy Tester
// Pipsgrowth EX16072 Trend — Execution Flow (from source analysis)
// Family: Trend
// Auto SL/TP manager that applies stop-loss and take-profit to open positions with lock-profit and trailing-stop features. Supports server-side or hidden (client) SL/TP and multiple trailing methods
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 |
|---|---|---|
| InpMagicNumber | 22216072 | Magic number |
| TakeProfit | 550 | Take Profit |
| StopLoss | 350 | Stop Loss |
| SLnTPMode | Server | SL & TP Mode |
| LockProfitEnable | LP_ENABLE | Enable/Disable Profit Lock |
| LockProfitAfter | 100 | Target point to Lock Profit |
| ProfitLock | 60 | Profit To Lock |
| TrailingStopMethod | TS_CLASSIC | Trailing Method |
| TrailingStop | 50 | Trailing Stop |
| TrailingStep | 10 | Trailing Stop Step |
| Slippage | 10 | Slippage |
| ChartSymbolSelection | AllOpenOrder | input bool inpEnableAlert=false;//Enable Alert |
| inpEnableTest | false | Enable Test on Strategy Tester |
#property copyright "Pipsgrowth.com"
#property link "https://pipsgrowth.com"
#property version "2.00"
#property strict
#property description "Pipsgrowth.com EX16072 Ronz SLTP MT5 — auto SL/TP manager with lock-profit and trailing stop, full 12-layer stack."
input long InpMagicNumber = 22216072; // Magic number
input string InpTradeComment = "Psgrowth.com Expert_16072";
#include <Trade\Trade.mqh> CTrade trade;
enum ENUM_CHARTSYMBOL
{
CurrentChartSymbol=0,//Current Chart Only
AllOpenOrder=1//All Opened Orders
};
enum ENUM_SLTP_MODE
{
Server=0,//Place SL n TP
Client=1 //Hidden SL n TP
};
enum ENUM_LOCKPROFIT_ENABLE
{
LP_DISABLE=0,//Disable
LP_ENABLE=1//Enable
};
enum ENUM_TRAILINGSTOP_METHOD
{
TS_NONE=0,//No Trailing Stop
TS_CLASSIC=1,//Classic
TS_STEP_DISTANCE=2,//Step Keep Distance
TS_STEP_BY_STEP=3 //Step By Step
};
sinput const string SLTP="";//=== SL & TP ===
input int TakeProfit=550;//Take Profit
input int StopLoss=350;//Stop Loss
input ENUM_SLTP_MODE SLnTPMode=Server;//SL & TP Mode
sinput const string Lock="";//=== Lock Profit ===
input ENUM_LOCKPROFIT_ENABLE LockProfitEnable=LP_ENABLE;//Enable/Disable Profit Lock
input int LockProfitAfter=100;//Target point to Lock Profit
input int ProfitLock=60;//Profit To Lock
sinput const string Trailing="";//=== Trailing Stop ===
input ENUM_TRAILINGSTOP_METHOD TrailingStopMethod=TS_CLASSIC;//Trailing Method
input int TrailingStop=50;//Trailing Stop
input int TrailingStep=10;//Trailing Stop Step
input int Slippage = 10; //Slippage
input ENUM_CHARTSYMBOL ChartSymbolSelection=AllOpenOrder;//
input bool inpEnableAlert=false;//Enable Alert
input bool inpEnableTest=false;//Enable Test on Strategy Tester
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class AutoSLTP
{
private:
//--
bool CheckMoneyForTrade(string sym, double lots,ENUM_ORDER_TYPE type);
bool CheckVolumeValue(string sym, double volume);
bool RZ_TrailingStop(ulong ticket, int JumlahPoin,int Step=1,ENUM_TRAILINGSTOP_METHOD Method=TS_STEP_DISTANCE);
bool LockProfit(ulong ticket, int Targetpoint,int Lockedpoint);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.