Liquidity Timed Partial Executor
A staged partial-exit plan - close a third of the position at one profit level, another third further on, and so on - is a common way to bank gains while letting the rest run. Firing that exit the instant its trigger profit is touched is simple, but a partial close filled during a thin trading session can give back more to spread and slippage than the staged exit was meant to lock in. This program tracks each managed position's original lot size and up to three independent profit triggers, each with its own close percentage computed against that fixed original size (not the shrinking remainder, so percentages do not compound unexpectedly across stages). When a trigger is reached, the stage does not fire immediately - it waits until the current server hour falls inside a configured "historically liquid" window before sending the partial close. Waiting is not unconditional. If price drifts back far enough while a stage sits armed and waiting for its window that the gain itself is at risk of disappearing, a configurable safety valve fires the exit immediately regardless of the window - the point of this EA is better average fills, not losing the exit altogether while queued for a session that may still be hours away. A partial close that would leave a remainder smaller than the broker's minimum lot is upgraded to a full close automatically, since a dust-sized remainder can be genuinely unclosable on some brokers. Notes and limitations - "Liquid window" here is whatever server hours you configure - this program has no market-data source for actual historical volume and does not infer the window itself; you supply it based on the symbol's known active sessions. - Stage percentages are computed against each position's ORIGINAL lot size at the time it was first tracked, not the remaining size after earlier stages - this keeps the three percentages meaning what they say rather than compounding. - A partial close that would leave less than the broker's minimum lot resting is closed in full instead of left as an unclosable dust remainder. - The drift safety valve compares current profit against each stage's own trigger, independently - it does not track the highest profit ever reached, only the gap from the trigger at the moment of evaluation. - Positions already carrying this EA's magic when it first attaches are picked up and tracked from their current lot size onward, not retroactively reconstructed from history.
Expert advisor · MT5 · v1.0 · Free
About Liquidity Timed Partial Executor
Liquidity Timed Partial Executor is an expert advisor (trading robot) for MetaTrader 5. It trades only in the hours you set (time filter). It has 13 settings, such as Magic filter, Symbol filter and Stage1 trigger pips. MQL source code included.
Files in the download: LiquidityTimedPartials.ex5, LiquidityTimedPartials.mq5, LiquidityTimedPartials.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Magic filter | 0 | Magic number of positions to manage |
| Symbol filter | Only manage this symbol; blank = every symbol | |
| Stage1 trigger pips | 20.0 | Profit distance that arms stage 1; 0 disables the stage |
| Stage1 close percent | 33.0 | Percent of the ORIGINAL volume closed at stage 1 |
| Stage2 trigger pips | 40.0 | Profit distance that arms stage 2; 0 disables the stage |
| Stage2 close percent | 33.0 | Percent of the ORIGINAL volume closed at stage 2 |
| Stage3 trigger pips | 60.0 | Profit distance that arms stage 3; 0 disables the stage |
| Stage3 close percent | 34.0 | Percent of the ORIGINAL volume closed at stage 3 |
| Liquid start hour | 12 | Liquid window start, server time, 0-23 (inclusive) |
| Liquid end hour | 16 | Liquid window end, server time, 0-23 (exclusive) - wraps past midnight if less than start |
| Max wait drift pips | 8.0 | Safety valve: fire outside the window if profit falls this far below the trigger |
| Max retries | 3 | Close attempts per stage before giving up |
| Retry wait ms | 300 | Pause between retry attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Trading Sessions · Time Filter · MT5 Expert Advisor · MQL5 Source Code