Cascade Exit Conductor
- Utilities
-
Syarief Azman Bin Rosli
Hello and welcome to my official MQL5 profile!
I am Syarief Azman Bin Rosli, an algorithmic trading systems developer and quantitative software engineer with over a decade of specialized experience creating robust automated trading solutions for MetaTrader 5 and MetaTrader 4. - Version: 1.0
- Activations: 5
Cascade Exit Conductor is a position-management utility for MetaTrader 5. It watches the trades you already have open - placed by hand or by any Expert Advisor - and runs their exits for you: it locks a breakeven stop, banks profit in a staged partial-exit cascade, trails the runner with an ATR or fixed distance, and can close a position after a maximum holding time. It is operated from a compact on-chart cockpit with one-click controls.
It never opens trades of its own and it does not predict direction. If you have no open positions, it simply idles and manages nothing.
What it does and does not do
- It DOES: move stops to breakeven, take partial profits in up to three steps, trail the remaining volume, and optionally time-close positions.
- It DOES NOT: open new orders, place pending orders, add to positions, martingale, grid, or hedge. It only reduces risk and manages exits on positions that already exist.
Quick Start
- Allow automated trading: in Tools > Options > Expert Advisors tick "Allow Algo Trading" (and enable the toolbar Algo Trading button). The utility sends close and modify requests, so this must be on.
- For mobile push alerts, set your MetaQuotes ID in Tools > Options > Notifications (only needed if you turn on Push Notifications To Mobile).
- Drag Cascade Exit Conductor onto any chart. One instance can manage every symbol; you do not need it on every chart.
- Choose the scope with Positions To Manage: "Current Chart Symbol Only" or "All Symbols".
- Confirm the cockpit shows ARMED (green LED). Open or already-hold a trade, and watch the Cascade ladder fill and the stop step up as price moves in your favor.
To verify it instantly: open a small manual trade in the managed scope, then click BE ALL NOW - the stop should jump to the entry price. Click FLATTEN 50% to close half. These confirm the utility controls your orders correctly.
Input Parameters
Every label below is the exact text shown in the input dialog.
Management Scope
- Master Automation Armed (default true): when false the utility only acts on the manual HUD buttons; all automatic management is paused. The ARM / DISARM button toggles this live.
- Positions To Manage (default Current Chart Symbol Only): choose "Current Chart Symbol Only" to manage only this chart's symbol, or "All Symbols" to manage every open position in the account.
- Filter By Magic Number (default false): when true, only positions whose magic number equals the value below are managed - use it to manage one EA's trades and leave others alone.
- Magic Number To Manage (default 0): the magic number to match when the filter is on. 0 targets manually opened trades.
Breakeven Lock
- Enable Breakeven Lock (default true): turn the breakeven stop on or off.
- Breakeven Trigger (pips in profit) (default 120): once the position is this many pips in profit, the stop is moved to the entry.
- Breakeven Offset (pips beyond entry) (default 10): where the stop lands relative to the entry - positive locks a small profit (entry + offset for a buy).
Partial Exit Cascade
- Enable Partial Exit Cascade (default true): turn staged partial closes on or off.
- Step 1 Trigger (pips) (default 150) and Step 1 Close (% of original volume) (default 35): at +150 pips, close 35% of the position's original volume.
- Step 2 Trigger (pips) (default 300) and Step 2 Close (% of original volume) (default 35): the second harvest.
- Step 3 Trigger (pips) (default 500) and Step 3 Close (% of original volume) (default 20): the third harvest. Percentages are of the ORIGINAL volume, so three steps of 35/35/20 leave 10% running. Set any step's values to 0 to skip it.
Trailing Stop
- Enable Trailing Stop (default true): turn trailing on or off.
- Trailing Mode (default ATR Distance): "ATR Distance" trails by ATR x multiplier (adapts to volatility); "Fixed Pips" trails by a constant distance.
- Activate Trailing After (pips) (default 200): trailing only starts once the position is this far in profit.
- Fixed Trail Distance (pips) (default 150): the gap kept behind price in "Fixed Pips" mode.
- ATR Period (ATR mode) (default 14): the ATR averaging length used in "ATR Distance" mode, on the chart timeframe.
- ATR Multiplier (ATR mode) (default 2.5): the ATR is multiplied by this to set the trail gap.
Time-Based Exit
- Enable Time-Based Exit (default false): close positions that have been open too long.
- Max Position Hold (minutes) (default 1440): maximum holding time in minutes before the position is closed (1440 = 24 hours).
Notifications
- Terminal Pop-Up Alerts (default true): show a pop-up Alert on every action.
- Push Notifications To Mobile (default false): send a push to the MetaTrader mobile app.
- Audible Alerts (default true): play a sound on every action.
HUD Cockpit Display
- Object Name Prefix (default CEC_): the prefix for every chart object; change it only if you run two copies on one chart.
- HUD Chart Corner (default Top Left): anchor corner - "Top Left", "Top Right", "Bottom Left" or "Bottom Right".
- HUD X Offset (pixels) (default 22) and HUD Y Offset (pixels) (default 30): the cockpit's distance from that corner.
- HUD Background (default dark slate), Accent Color (cyan), Profit / Armed Color (green) and Loss / Alert Color (red): the cockpit palette.
The On-Chart Cockpit
The cockpit is a dark multi-layer panel with a header strip, a live status block, one row per managed position, a progress meter and an action deck.
Header: a status LED dot - green when ARMED, amber when DISARMED - next to the title CASCADE EXIT CONDUCTOR, and a [-] button that collapses the panel to a compact pill; click the [+] on the pill to restore it. Collapsed, the title line reads, for example, "CEC ARMED | 2 pos | +$340.00".
Status block:
- Mode line, e.g. "Chart | ARMED | Trail:ATR". The first field is the scope ("Chart" or "AllSym"), the second is ARMED or DISARMED, the third is the trailing mode (Trail:ATR, Trail:Fix or Trail:Off).
- "Managing N pos X.XX lots" with the aggregate floating profit of all managed positions, green when positive and red when negative.
Position rows (up to four shown): each row reads "SYMBOL BUY/SELL ladder flags profit". The ladder is five cells; a filled cell means a completed cascade step (three filled = all three partials done). The flags are two letters: a B appears once breakeven is locked, a T once trailing is active (a dash means not yet). BUY or SELL marks the side, and the profit is that position's floating result.
Action deck (four buttons):
- ARM / DISARM - toggles Master Automation Armed. Disarmed, automatic management stops but the other buttons still work.
- BE ALL NOW - immediately moves every managed position's stop to its breakeven level.
- FLATTEN 50% - closes half of every managed position at market.
- CLOSE ALL - closes every managed position at market.
Automatic Behavior
On a fast internal timer and on every tick, for each in-scope position the utility, in order:
- Time exit: if enabled and the position has been open at least Max Position Hold minutes, it is closed.
- Partial cascade: when profit reaches Step 1/2/3 Trigger, the matching Step Close percentage of the ORIGINAL volume is closed. If the remainder would fall below the broker minimum lot, the step closes the position in full instead.
- Breakeven lock: at Breakeven Trigger pips, the stop is set to entry +/- Breakeven Offset. The stop is only ever moved forward, never loosened.
- Trailing stop: past Activate Trailing After pips, the stop follows price by the ATR or fixed distance, only ever tightening, and never back below a locked breakeven.
Safety: before any close or modify the utility checks the symbol is tradable and that price is not inside the broker stop/freeze level; if it is, the action is deferred to the next tick rather than sent and rejected. All stop prices are normalized to the symbol's digits and respect the minimum stop distance.
Notifications, Side Effects and Scope
- Every action prints to the Experts log and, depending on your settings, raises a terminal Alert, a mobile push and a sound. All messages carry the prefix [Cascade Conductor].
- The utility writes no files and sets no terminal global variables. The only chart objects it creates are the cockpit elements, all under the Object Name Prefix; they are removed cleanly when it is detached.
- Its own stop/take-profit modifications are tagged with magic number 771144; it manages positions by the scope and magic filter above, not by that tag.
Typical Setups
- Intraday forex runner: Breakeven Trigger 120, cascade 150/300/500 at 35/35/20, ATR trailing period 14 x 2.5, Enable Time-Based Exit off.
- Gold / index scalp (remember a "pip" is 10 points on 5/3-digit symbols and 1 point on 2-digit gold, so size the triggers to the instrument): smaller triggers, Fixed Pips trailing.
- Set-and-forget EA assistant: Filter By Magic Number true with that EA's magic, cascade on, trailing on, so your EA's entries are managed to the exit automatically.
Notes and Risk
A "pip" here is 10 points on 5-digit and 3-digit symbols and 1 point on others; check the distances suit your symbol. The utility reduces exposure and automates exits - it cannot prevent slippage, gaps or losing trades, and it does not guarantee any profit or result. Test it on a demo account first. Trading carries risk; past or simulated behavior does not guarantee future results.
