EA Not Working? 5 Debugging Tips
rfxsignals October 14, 2025 No Comments
EA Not Working? 5 Debugging Tips
EA Not Working? 5 Debugging Tips | YOUR_DOMAIN

EA Not Working? 5 Debugging Tips for MT4/MT5

By Approx. 9–12 min read
When your EA refuses to trade, don’t panic. Use these five practical debugging steps to identify configuration, code, or environment issues and get your Expert Advisor running reliably.

Expert Advisors (EAs) automate trading decisions on MetaTrader 4 and 5, but they don’t always work perfectly out of the box. Problems can come from incorrect inputs, missing permissions, broker limitations, logical bugs in the code, or even platform quirks. This guide walks through five focused troubleshooting steps — logs, strategy tester, inputs & settings, broker/account checks, and environment verification — to systematically isolate and fix the issue.

1. Check the logs — start with the obvious

MT4/MT5 writes useful debug information. Open the Experts and Journal tabs in the Terminal window. Look for errors like "trade context is busy", "not enough money", or custom Print() messages you added to the EA. Logs often reveal permission issues (AutoTrading off), rejected orders, or repeated exceptions.

Tip: Add verbose logging during development. Use Print() in MQL to output variable values and decision branches. For MT5, use `PrintFormat()` to include timestamps or variable states. Remember to remove or reduce verbose logging in production to avoid performance issues.

2. Reproduce the problem in the Strategy Tester

The Strategy Tester is your friend. Run the EA in the strategy tester with visual mode and realistic tick data if possible. Reproducing the issue offline helps you debug deterministic logical errors without risking capital. Pay attention to:

  • Order execution flow — does the EA attempt to open orders but receives rejections?
  • Margin calculations — does the tester show "not enough margin" at specific moments?
  • Timeframe mismatches — are you testing on a chart timeframe different from EA expectations?

3. Verify inputs, symbol, and timeframe settings

Many EAs fail because of innocuous input mistakes. Check the following:

  • Magic number and symbol — ensure the EA is set to operate on the correct symbol or has `Symbol()` usage coded correctly.
  • Lot size limits — brokers have min/max lot sizes and step sizes; sending an unsupported lot will get rejected.
  • Trade permissions — confirm AutoTrading / AlgoTrading is enabled and the EA is allowed to trade in the EA settings.
  • Time filters — some EAs include built-in session filters; make sure your local time or broker time aligns with the EA's time zone assumptions.

4. Check broker and account restrictions

Broker-specific constraints commonly break EAs. Verify:

  • Account type — some brokers restrict scalping, EAs, or require specific account classes for automated trading.
  • Hedging vs netting — MT5 accounts can be hedging or netting; EAs written for hedging may fail on netting accounts.
  • Minimum margin and leverage — ensure the EA's position sizing logic respects your account leverage and minimum margin rules.
  • Server-side issues — check broker news/announcements or contact support if orders are repeatedly rejected for unclear reasons.

5. Environment checks — platform, indicators, and external dependencies

Modern EAs often depend on custom indicators, DLLs, or external data. Confirm that:

  • All required custom indicators are installed in the correct `Indicators` folder and compiled for the right platform (MT4 vs MT5).
  • Any included DLLs are present and allowed (MT4 only) and that library calls are permitted in platform settings.
  • File and network access (if used) is permitted — check `Allow DLL imports` and `Allow WebRequest` lists as needed.
  • Your platform build is up to date — sometimes bugs are fixed in platform updates that affect EA behavior.

Troubleshooting checklist and quick fixes

Quick checklist

  1. Is AutoTrading / AlgoTrading enabled?
  2. Do logs show rejected orders or exceptions?
  3. Does the Strategy Tester reproduce the issue?
  4. Are input values compatible with broker limits?
  5. Are all external dependencies installed and allowed?

Debugging patterns and examples

Example 1 — "Trade context is busy": This error happens when the EA tries to open/modify orders while another trade operation is in progress. Use `Sleep()` or check `IsTradeContextBusy()` (MT5) before sending orders to avoid collisions.

Example 2 — "Not enough money": Usually position sizing logic is wrong or the tester uses different margin. Recompute lot size based on `AccountFreeMargin()` and the broker's contract specification.

Example 3 — Timeframe mismatch: An EA that assumes 1-hour bars but runs on M15 may never find the expected pattern. Ensure your EA either adapts to chart timeframe or enforces the correct timeframe on attach.

Best practices to avoid future EA issues

  • Instrument defensive coding: check return values for all trade operations and handle errors gracefully.
  • Implement detailed, conditional logging that can be toggled by an input parameter.
  • Use version control for your MQL projects and keep change logs when deploying updates to live accounts.
  • Maintain a staging/demo account that mirrors your live setup for safer testing.

Where to get help

If you’re stuck, consider these resources:

  • EA documentation or author's support forum
  • MQL5 community scripts and code examples
  • Professional developer help — hire an MQL developer for a code review

Related reading

Conclusion

When an EA is not working, systematic debugging saves time and frustration. Start with logs, reproduce problems in the Strategy Tester, verify inputs and broker restrictions, and check the platform environment. With disciplined troubleshooting you'll usually find the root cause quickly — and if not, documentation and community resources are excellent next steps.


Disclaimer: This article is educational and does not guarantee that every EA problem will be resolved. Always test changes in a demo environment first.