Loading…

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

SettingDefaultWhat it does
Inbox folderCommandFileRepl\\InboxSubfolder of MQL5\Files scanned for *.cmd scripts
Results folderCommandFileRepl\\ResultsSubfolder where '<script>.result' files are written
Script extension.cmd
Scan interval seconds2
Max lots per order1.0Hard cap regardless of what a script line requests
Magic number44700Magic number that tells this EA's orders apart
Allow tradingfalsefalse = BUY/SELL/CLOSE_ALL lines are parsed and logged as REFUSED, never sent
Max retries5
Retry wait ms500

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Buy/Sell Arrows · Trading Sessions · Risk & Lot Size · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria