Can ChatGPT write a profitable EA?
Short answer: ChatGPT and other AI tools can write MT5 Expert Advisor (EA) code, often code that compiles and places trades. But writing code is not the same as having an edge. An AI does not know a profitable strategy by default. Ask it for "a profitable gold EA" and you get a working robot that follows rules someone guessed. Whether it makes money is a question only testing can answer.
This page explains what AI can and cannot do when it writes an EA, and the method we use to test AI-made EAs in public.
Why this question matters now
MetaTrader 5 now has AI built into MetaEditor: build 6060 (23 Jul 2026) is titled "AI Integration, Passkey, and Code Management Improvements in MetaEditor" (MT5 release notes). More traders will build EAs with AI, so an honest test method matters more, not less.
Want to try it? Our guide shows how to use the MetaEditor AI assistant step by step.
What AI is good at when writing an EA
- Boilerplate code: inputs, order functions, magic numbers, simple indicators, a basic trailing stop.
- Turning clear rules into code: "buy when the 20 EMA crosses above the 50 EMA on M15, stop loss 2 × ATR" is usually easy for an AI.
- Explaining and fixing errors: paste the compiler error and it can often fix it.
- Speed: a first version in minutes instead of days.
What AI gets wrong (and what to check)
- MQL4/MQL5 mix-ups. AI often mixes old MQL4 functions into MQL5 code, or uses functions that do not exist. Always compile in MetaEditor and read every warning.
- Silent logic bugs. Code that compiles can still be wrong: lot size in the wrong unit, stop loss on the wrong side, no check for open positions, no limit on open trades. These bugs show no error. They show up as losses.
- No edge by default. An AI has no private knowledge of what makes money. It gives you common ideas from public text, and common ideas are rarely an edge on their own.
- Overfitting when you "optimise" with AI. Asking the AI to change settings until the backtest looks good fits the past. Research on backtests shows simple hold-out checks "tend to be unreliable" for investment backtests (Bailey et al., The probability of backtest overfitting).
- Weak backtests. The MT5 tester has several tick modes. "1 minute OHLC" builds ticks only from minute bars; "Real ticks" uses the broker's tick history when it exists (MQL5 book). A great result in a rough mode can disappear in a finer one.
- Hidden risk. Ask for "high win rate" and you may get a grid or martingale EA: many small wins, then one very large loss. Check how the EA adds to losing trades before you look at profit.
How we test AI-made EAs
We do not rank AI-made EAs by profit. We rank them by survival.
- Same prompt for every AI. ChatGPT, Claude, Gemini and DeepSeek each get the same plain prompt: one gold (XAUUSD) EA on M15.
- Compile and read the code. We fix only compile errors and write down every fix. No hand-tuning of the strategy.
- Backtest in the finest tick mode available, with realistic spread.
- Forward test on its own demo account, so results never mix.
- Survival checks: worst floating loss, deepest drawdown, time running, grid or martingale. See the Survival lab and the Grid calculator.
- Prop firm rule check: would it break a daily or max loss rule? See Prop check.
The race runs on the AI EA Arena. It has not started yet, so there are no results to show.
Checklist before you trust an AI-made EA
- It compiles in MetaEditor with no errors, and you read the warnings.
- You can explain every entry and exit rule in one sentence each.
- Lot size, stop loss and max open trades are fixed and limited.
- No grid or martingale, or you know exactly how far price can move before it breaks.
- Backtest in the finest tick mode, with spread and commission like your broker.
- Test years with different market moods, not only the last few months.
- Change one setting a little. If the result collapses, the edge is weak.
- Run it on demo for weeks before any real money.
FAQ
Can ChatGPT write a profitable EA?
It can write the code. It cannot promise profit. Profit depends on the strategy and on testing, not on who wrote the code.
Is AI-written MQL5 code safe to run live?
Not without checks. Compile it, read the logic, backtest in a fine tick mode, then run it on demo first. Watch lot size and stop loss for silent bugs.
Which AI writes the best EA: ChatGPT, Claude, Gemini or DeepSeek?
We do not know yet, and we will not guess. We test them side by side on demo accounts in the AI EA Arena.
Sources: MT5 release notes, MQL5 book (tester tick modes), Bailey, Borwein, López de Prado and Zhu (Journal of Computational Finance). Opened 17 Oct 2026.