$npx -y skills add kecoma1/MQL5-SKILLS --skill interfaceUse the local MetaTrader 5 Python trading CLI at MQL5\Scripts\interface.py. Use when Codex needs to explain, run, validate, or troubleshoot command-line trading operations such as opening market or pending orders, setting or editing SL/TP, closing positions, canceling pending ord
| 1 | # Interface |
| 2 | |
| 3 | Use this skill for the local MT5 Python CLI wrapper located at: |
| 4 | |
| 5 | `C:\Users\kecom\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Scripts\interface.py` |
| 6 | |
| 7 | The script is intended to operate MetaTrader 5 through the Python `MetaTrader5` package. Treat it as a live-trading interface: do not submit market, pending, close, edit, or cancel commands unless the user explicitly asked for that action and the target account/symbol/ticket/volume/stops are clear. |
| 8 | |
| 9 | ## Before Running |
| 10 | |
| 11 | 1. Work from the script directory unless there is a reason not to: |
| 12 | |
| 13 | ```powershell |
| 14 | cd C:\Users\kecom\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Scripts |
| 15 | ``` |
| 16 | |
| 17 | 2. Confirm a real Python executable is available. If `python` resolves to `C:\Users\kecom\AppData\Local\Microsoft\WindowsApps\python.exe`, it may hang or open the Microsoft Store alias instead of running scripts. |
| 18 | |
| 19 | 3. Confirm the package is installed when execution is required: |
| 20 | |
| 21 | ```powershell |
| 22 | python -m pip install MetaTrader5 |
| 23 | ``` |
| 24 | |
| 25 | 4. Confirm MetaTrader 5 is installed, logged in, and allowed to trade. If needed, pass `--terminal`, `--login`, `--password`, and `--server`. |
| 26 | |
| 27 | 5. For read-only inspection, prefer `--cmd=help`, `--cmd=opened`, `--cmd=orders`, `--cmd=history`, `--cmd=account`, and `--cmd=symbol`. |
| 28 | |
| 29 | ## Core Commands |
| 30 | |
| 31 | Show the built-in help: |
| 32 | |
| 33 | ```powershell |
| 34 | python interface.py --cmd=help |
| 35 | ``` |
| 36 | |
| 37 | Open a market buy using SL/TP distances in points: |
| 38 | |
| 39 | ```powershell |
| 40 | python interface.py --cmd=open --type=buy --market=EURUSD --lot=0.10 --sl-points=200 --tp-points=400 |
| 41 | ``` |
| 42 | |
| 43 | Open a pending buy limit using absolute SL/TP prices: |
| 44 | |
| 45 | ```powershell |
| 46 | python interface.py --cmd=open --type=buylimit --market=EURUSD --lot=0.10 --price=1.08000 --SL=1.07500 --TP=1.09000 |
| 47 | ``` |
| 48 | |
| 49 | Close one open position by ticket: |
| 50 | |
| 51 | ```powershell |
| 52 | python interface.py --cmd=close --id=322334 |
| 53 | ``` |
| 54 | |
| 55 | Close all positions, optionally filtered by market: |
| 56 | |
| 57 | ```powershell |
| 58 | python interface.py --cmd=close --all --market=EURUSD |
| 59 | ``` |
| 60 | |
| 61 | Edit SL/TP on an open position or pending order: |
| 62 | |
| 63 | ```powershell |
| 64 | python interface.py --cmd=edit --id=23232 --TP=1.09250 |
| 65 | python interface.py --cmd=edit --id=23232 --sl-points=150 --tp-points=300 |
| 66 | ``` |
| 67 | |
| 68 | Cancel a pending order: |
| 69 | |
| 70 | ```powershell |
| 71 | python interface.py --cmd=cancel --id=998877 |
| 72 | ``` |
| 73 | |
| 74 | List current positions: |
| 75 | |
| 76 | ```powershell |
| 77 | python interface.py --cmd=opened |
| 78 | python interface.py --cmd=opened --market=EURUSD |
| 79 | ``` |
| 80 | |
| 81 | List pending orders: |
| 82 | |
| 83 | ```powershell |
| 84 | python interface.py --cmd=orders |
| 85 | python interface.py --cmd=orders --market=EURUSD |
| 86 | ``` |
| 87 | |
| 88 | Read recent history. The misspelled alias `hystory` is accepted for compatibility: |
| 89 | |
| 90 | ```powershell |
| 91 | python interface.py --cmd=history --last=10 |
| 92 | python interface.py --cmd=hystory --last=10 --market=EURUSD |
| 93 | ``` |
| 94 | |
| 95 | Check account or symbol details: |
| 96 | |
| 97 | ```powershell |
| 98 | python interface.py --cmd=account |
| 99 | python interface.py --cmd=symbol --market=EURUSD |
| 100 | ``` |
| 101 | |
| 102 | ## Parameter Rules |
| 103 | |
| 104 | Use `--SL` and `--TP` for absolute prices only. Example: `--SL=1.07500`, not `--SL=23` unless 23 is truly the broker price. |
| 105 | |
| 106 | Use distance parameters when the user describes stops in points or pips: |
| 107 | |
| 108 | ```powershell |
| 109 | --sl-points=200 --tp-points=400 |
| 110 | --sl-pips=20 --tp-pips=40 |
| 111 | ``` |
| 112 | |
| 113 | Use `--price` for pending order entry price. Market orders can omit `--price`; the script uses the current ask for buys and bid for sells. |
| 114 | |
| 115 | Use `--stoplimit` for `buystoplimit` and `sellstoplimit` orders. |
| 116 | |
| 117 | Use `--lot` or `--volume` for trade volume. |
| 118 | |
| 119 | Use `--deviation` for allowed slippage in points on market entries and closes. |
| 120 | |
| 121 | Use `--filling` when the broker rejects the default filling mode. Valid values are `ioc`, `fok`, `return`, and `boc`. |
| 122 | |
| 123 | Use `--json` when another script needs machine-readable output. Use `--dry-run` to build and print an MT5 trade request without sending it to the broker. |
| 124 | |
| 125 | ## Safety Workflow |
| 126 | |
| 127 | Before sending live-trading commands, restate the exact operation in concrete terms: command, symbol, type, volume, price if pending, SL, TP, ticket if applicable, and whether values are absolute prices or distances. |
| 128 | |
| 129 | If the user provides ambiguous stops like `SL=23`, ask whether they mean an absolute price, points, or pips before executing. Do not convert ambiguous stop values silently. |
| 130 | |
| 131 | If the user asks only how to do something, provide commands and avoid running them. If testing an order workflow, use `--dry-run` first. |
| 132 | |
| 133 | If MT5 returns a non-success `retcode`, report the `retcode`, `retcode_name`, and `comment`. Suggest the smallest relevant next check, such as symbol visibility, filling mode, invalid stops, market closed, insufficient margin, or wrong ticket typ |