Can ChatGPT or other AI write a working Expert Advisor?
By Praveen Divvala · · 4 min read
Short answer
AI assistants such as ChatGPT can draft MQL4 or MQL5 code quickly and are useful for prototypes, but AI-written Expert Advisors often fail in ways that cost money: mixing MT4 and MT5 functions, mishandling orders and broker rules, and skipping risk checks. Before trading real money, have the code reviewed, fixed and back-tested by someone who knows MQL.
What AI does well
AI can turn a plain description into a first draft quickly, explain unfamiliar MQL functions, and suggest a structure for an EA. For learning and for sketching an idea, that is genuinely useful.
Where AI-written EAs commonly go wrong
Most of these do not show up until the EA meets a real broker, which is the most expensive place to find them.
- Mixing MQL4 and MQL5: MT4 order functions in MT5 code, or the reverse, so it will not compile or behaves oddly
- Order handling: ignoring stop levels, lot steps, filling modes or requotes, so orders are rejected live
- Netting vs hedging accounts: logic that assumes one position per symbol when the account allows several
- Missing risk controls: no stop-loss on every order, no daily loss or drawdown guard
- Untested edge cases: weekends, gaps, disconnections, and what happens after a restart
A safe way to use AI-generated code
Treat AI output as a draft. Have it reviewed against your actual rules, fixed for your platform and broker, given proper risk management, then back-tested and forward-tested on a demo account before it touches a live or funded account.
General information about software and trading platforms, not investment advice. Trading leveraged products carries a high risk of loss. See the risk disclosure.

