Order Lifecycle Demonstrator
Most order handling bugs in beginner code come from a mental model that skips a state, or - for anyone porting from MQL4 to MQL5 - from carrying MQL4's model over unchanged when MQL5's is genuinely different. Reading about this is not as convincing as watching a real ticket move through the states with each transition narrated as it happens. Disarmed by default, this EA runs a fully narrated simulated walkthrough - illustrative ticket numbers, no trade server contact at all - so it is safe to drop onto any chart, any account, purely to read the narration. Setting InpArmLiveDemo to true switches it to a genuine live demonstration: it sends one real minimum-lot pending order, polls it every tick, and narrates each real state change including a live modify to break-even once the position triggers, right through to the close. The live mode does place a real trade and is clearly warned as such in the input's own description. Notes and limitations The simulated mode uses illustrative ticket numbers and timed stages purely for narration - it never contacts the trade server and proves nothing about this specific broker's behaviour. The live mode places one real minimum-lot trade with a stop and target attached; use a demo account. If the live pending order's distance falls inside the broker's minimum stop distance for the current symbol, the demo reports that plainly and does not send the order.
Expert advisor · MT5 · v1.0 · Free
About Order Lifecycle Demonstrator
Order Lifecycle Demonstrator is an expert advisor (trading robot) for MetaTrader 5. It places pending buy/sell stop or limit orders. It has 5 settings, such as Pending offset pips, Stop loss pips and Take profit pips. MQL source code included.
Files in the download: OrderLifecycleDemonstrator.ex5, OrderLifecycleDemonstrator.mq5, OrderLifecycleDemonstrator.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 |
|---|---|---|
| Pending offset pips | 5 | Distance from current price for the live demo's pending order, in pips |
| Stop loss pips | 20 | Stop loss for the live demo's order, in pips |
| Take profit pips | 20 | Take profit for the live demo's order, in pips |
| Magic number | 20261211 | Magic number for the live demo's order |
| Slippage pips | 3 | Slippage tolerance for the live demo, in pips |
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: Pending Orders · MT5 Expert Advisor · MQL5 Source Code