Portfolio Peak2Valley Preserver
- Утилиты
- Версия: 3.2
- Активации: 10
SQXHK presents
MetaTrader 5 Expert Advisor: Portfolio Peak2Valley Preserver EA (MAE/MFE Enhanced)
Developer: SQX.hk
Visit SQX.hk for data science trading skills course using "StrategyQuant X" and AI Data Science platform "Tradotcom.com"!
Take absolute control of your portfolio's exit strategy with Peak-to-Valley Profit Preserver EA. Designed as a utility expert advisor, this tool continuously monitors your account's aggregate open positions and pending orders, executing an institutional-grade, mathematical exit sequence based on your strategy's historical MAE (Maximum Adverse Excursion) and MFE (Maximum Favorable Excursion) metrics, computed from "SQXHK Hourly PnL Analyser for VaR 及 CVaR 估算" offered during SQXHK StrategyQuant MasterClass lesson.
Whether you trade ranging market, breakout market, trending market or a combination of them, Profit Preserver EA acts as your ultimate automated circuit breaker—securing profits precisely when your statistical targets are reached and safely flatlining the account.
💎 Key Features
-
Advanced MAE/MFE Exit Matrix: Calculates exact profit target using the historical performance (MAE/MFE) metrics of your strategies portfolio.
-
Auto or Custom Equity Baselines: Automatically locks in your starting equity at launch, or allows you to specify a fixed dollar baseline.
-
Smart Alert Throttling: Prompts real-time platform alerts if your running portfolio P/L breaches your specified MAE or MFE levels, using built-in timers to prevent alert flooding.
-
Full Housekeeping Control: Configurable choices to close all active open positions, purge left-over pending orders, or both.
-
Terminal Hard-Stop: Safely kills a global trading flag and shuts down the entire MetaTrader 5 terminal process after execution to prevent unwanted re-entries by other bots.
-
Remarks: The Profit Preserver EA will ONLY hard-stop your MT5 terminal when the profit target is reached. It WILL NOT stop your MT5 terminal when account equity falls below designated MAE level but WILL only produce notification.
📐 The Execution Formula
The EA implements a strict statistical matrix. It treats both input metrics as absolute values to find your portfolio's expected volatility band, then applies an optional percentage buffer:
Target P/L = (1 + Percentage%) * (Portfolio MAE + Portfolio MFE)
Once your account's running open P/L matches or exceeds this target, the exit routine triggers instantly, terminating your MT5 terminal at the end.
⚙️ Input Parameters Explained
Core Settings & Housekeeping
-
Slippage / Deviation for Closes ( InpDeviationPoints ): Maximum allowed slippage (in points) when executing market closures.
-
Verbose Logging ( InpLogVerbose ): Enable detailed logs in the terminal experts tab for explicit tracking.
-
Delete Pending Orders ( InpDeletePendingOrders ): If true , all limits and stops are purged upon target hit.
-
Close Open Positions ( InpClosePositions ): If true , flattens all open exposure across the entire account.
-
Close Terminal After Action ( InpCloseTerminalAfterAction ): Sets a global variable ( GLOBAL_EA_TRADING = 0 ) and safely closes down the MT5 terminal completely.
-
MS to Wait After Global Flag ( InpWaitAfterFlagMs ): Brief delay to ensure database state writing before terminal termination.
Baselines & MAE / MFE Inputs
-
Custom Starting Equity ( InpCustomStartingEquity ): Define a fixed balance/equity starting line. Leave at 0.0 for automatic detection upon attachment.
-
Portfolio MAE ( InpPortfolioMAE ): Your maximum expected drawdown point from reports (inputted as a negative signed value).
-
Portfolio MFE ( InpPortfolioMFE ): Your maximum expected profit run-up value.
-
Enable Take Profit ( InpEnableMaeMfeTakeProfit ): Activates the automated formula-based mathematical exit loop.
-
Additional Percentage ( InpAdditionalPercent ): Add a padding percentage on top of the calculated MAE+MFE baseline target.
Timing & Loop Thresholds
-
Evaluation Interval ( InpCheckIntervalSeconds ): How frequently (in seconds) the EA recalculates the equity and profit math (Timer-based loop independent of tick volume).
-
Prompt Alert Interval ( InpAlertIntervalMinutes ): Throttling timer (in minutes) defining how often the EA is allowed to prompt visual alerts to the screen when limits are breached.
Useful for:
-
Prop Firm traders managing tight trailing drawdowns.
-
Portfolio managers supervising overlapping automated strategies.
-
Manual traders who want to eliminate psychological hesitation at profit targets.
Visit SQX.hk and join our Whatsapp community!
