Why Will It Not Trade Doctor
"Why won't it trade" has roughly eight independent causes, and MetaTrader never reports which one applies - an Expert Advisor that fails one of these gates simply never sends an order, with no message anywhere pointing at the reason. Traders end up guessing: toggling the AutoTrading button, re-checking a password, restarting the terminal, in whatever order occurs to them first. This script checks all eight in the order MetaTrader itself evaluates them. Global gates that block every symbol at once - the AutoTrading button, this program's "Allow live trading" permission, the account's trade and EA permissions, the connection to the trade server, and whether the trade context is currently busy - are checked before anything symbol-specific, because a global gate makes every downstream check moot regardless of what it finds. Symbol-level gates - SYMBOL_TRADE_MODE (cross-checked against the older MarketInfo(MODE_TRADEALLOWED) boolean some brokers still keep separately), whether the market session looks open from quote freshness, and whether the account can actually afford a minimum-size order right now - are checked second, and only matter once every global gate is open. The output names the FIRST closed gate as the current cause, not every closed gate at once. A trader who fixes that one and re-runs the script sees whatever the next real blocker is, rather than a static list that does not update as problems get resolved one at a time. Notes and limitations This is diagnostic, not corrective - it never places, modifies or closes an order, and it never changes any terminal or account setting. It only reports what it finds. The market-session check infers "open" from how recently the symbol produced a quote, since MQL4 exposes no direct session-open flag through MarketInfo(). A very quiet but genuinely open market can occasionally look stale by this measure; the other nine gates are read directly from the platform and do not have this limitation. If every gate reports open and an order still fails, the cause is order-level (invalid stops, wrong volume step, a requote) rather than a permission, session or margin gate - a stops-specific diagnostic covers that class of failure.
Script · MT4 · v1.0 · Free
About Why Will It Not Trade Doctor
Why Will It Not Trade Doctor is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Symbol and Test lots. MQL source code included.
Files in the download: WhyNotTradingDoctor.mq4, WhyNotTradingDoctor.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to check (blank = current chart symbol) | |
| Test lots | 0.01 | Lot size used only to test the margin gate |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Trading Sessions · Alerts · MT4 Script · MQL4 Source Code