Create a trading EA with AI (ChatGPT, Claude, Gemini)
A few years ago, building a trading robot meant knowing how to code in MQL. Today, you describe your strategy in plain English to an AI and it writes the Expert Advisor for you. This guide shows which AI to choose, the exact workflow, a ready-to-copy prompt, and the one limit no robot seller will tell you.
Why create an EA with AI
The big blocker to automating a strategy used to be programming. AI removes it: you state your logic in plain language, it translates it into MQL4 or MQL5. You save hours, test ten ideas in the time it took to code one, and you no longer need to hire a developer for a first prototype.

Which AI to choose
All major AIs can write MQL, but some are more comfortable with code:
- Claude (Anthropic) and ChatGPT (OpenAI): the two most comfortable with MQL5, generating clean, well-commented code. Our two favourites for a readable EA.
- Gemini (Google), DeepSeek and Grok: get the job done, useful for comparing versions.
The smart move: ask two AIs for the same EA and keep the clearer code. None of them knows your strategy's profitability, but they save you the tedious part.
The 5-step workflow
- Describe your strategy: entry and exit rules, stop loss, take profit, lot size, timeframe.
- Ask for the code explicitly "in MQL5 for MetaTrader 5" (or MQL4 for MT4), ready to compile.
- Paste into MetaEditor and compile (F7).
- Feed errors back to the AI, copy-paste the message, it fixes them.
- Backtest in the Strategy Tester, then on a demo account.
A ready-to-copy prompt
The more precise your prompt, the better the code. Here's a template for a simple moving-average crossover EA, to adapt to your strategy:
You are an expert MQL5 developer. Write an Expert Advisor for MetaTrader 5.
Strategy:
- Crossover of two exponential moving averages (EMA 12 and EMA 26)
- Buy when EMA 12 crosses above EMA 26
- Sell when EMA 12 crosses below
- Stop loss: 50 pips, Take profit: 100 pips
- Position size: 0.01 lot, configurable
- Only one open position at a time
Use the CTrade class. Comment the code in English.
Give me the full .mq5 file, ready to compile.Then iterate: "add a trailing stop", "don't open positions on Friday evening", "add a trend filter with an EMA 200". The AI edits the code as you go. To understand the structure it returns, keep our how to create a MetaTrader EA guide handy.
The limit nobody tells you
An AI writes code that compiles and does what you describe. It doesn't know whether your strategy wins. An EA generated in three minutes can lose money live if the strategy is bad. Be wary of "miracle AI EAs" sold online: if an automated martingale paid out for sure, nobody would sell it to you. The real value is your strategy and your risk management, not the fact that the code came from an AI.
Test then run your EA
Before going live, two mandatory steps: the backtest (Strategy Tester) over a long period, then a demo account for several weeks. When you go live, you need a MetaTrader broker that accepts EAs. Axi (CySEC-regulated) and BlackBull offer MT4 and MT5 with fast execution suited to automated trading: Axi account or BlackBull account. And to install the EA once generated, follow our how to install an EA guide.
FAQ
Can you really create an EA with ChatGPT or AI?
Yes. Claude, ChatGPT, Gemini, DeepSeek and Grok write working MQL4/MQL5. You describe, the AI codes, you compile and feed errors back.
Which AI for coding an EA?
Claude and ChatGPT are the most comfortable with MQL5. Compare two AIs and keep the cleaner code.
Is an AI-built EA profitable?
Not automatically. The AI codes your strategy, it doesn't make it win. Backtest and test on demo.
Disclaimer. Automated trading via EAs carries a high risk of rapid capital loss due to leverage. AI-generated code and a positive backtest do not guarantee future results. Most retail accounts lose money. This article is educational and not investment advice.
