Command File REPL
Automating a terminal action from outside MetaTrader usually means either the Strategy Tester (which cannot touch a live/demo session) or a one-shot signal file (which can only ever say one thing). This EA is a small batch REPL instead: drop a plain-text script with one instruction per line into the watched inbox, and every line is executed in order, with its result or error appended to a '<script>.result' file that any external process can read back afterward. The instruction set is deliberately small - PING, BALANCE, EQUITY, MARGIN, COUNT_OPEN, BUY/SELL with lots and optional SL/TP pips, CLOSE_ALL, and a capped SLEEP - covering the kind of end-to-end smoke test a build pipeline or a test harness actually wants ("open a small position, check it exists, close everything, confirm zero open") without exposing anything close to a general scripting surface. A script only ever runs once: the instant it is fully read it is renamed to '<name>.done' inside the same inbox folder, which both prevents the folder scan from ever replaying it and leaves an audit trail of what has already run. Notes and limitations This is a batch tool, not a low-latency one - scripts are only picked up on the InpScanIntervalSeconds timer, and a SLEEP line blocks the whole OnTick handler for up to 30 seconds (capped deliberately so one script line can never freeze the EA indefinitely). The instruction grammar is intentionally minimal. There is no conditional logic, no variable, no loop - each line is independent and the file is a flat sequence. Anything more sophisticated than the fixed verb list returns an "ERROR unknown verb" result line rather than being interpreted loosely. CLOSE_ALL only closes orders carrying InpMagicNumber - it will never touch a position opened manually or by a different EA/magic number on the same chart.
Expert advisor · MT5 · v1.0 · Free
About Command File REPL
Command File REPL is an expert advisor (trading robot) for MetaTrader 5. It can size trades from your balance and risk percent. It has 9 settings, such as Inbox folder, Results folder and Script extension. MQL source code included.
Files in the download: CommandFileRepl.ex5, CommandFileRepl.mq5, CommandFileRepl.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 |
|---|---|---|
| Inbox folder | CommandFileRepl\\Inbox | Subfolder of MQL5\Files scanned for *.cmd scripts |
| Results folder | CommandFileRepl\\Results | Subfolder where '<script>.result' files are written |
| Script extension | .cmd | |
| Scan interval seconds | 2 | |
| Max lots per order | 1.0 | Hard cap regardless of what a script line requests |
| Magic number | 44700 | Magic number that tells this EA's orders apart |
| Allow trading | false | false = BUY/SELL/CLOSE_ALL lines are parsed and logged as REFUSED, never sent |
| Max retries | 5 | |
| Retry wait ms | 500 |
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: Buy/Sell Arrows · Trading Sessions · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code