How to Use the MetaEditor AI Assistant to Write and Fix MQL5 EAs
MetaTrader 5 now has a built-in AI assistant in MetaEditor. You can ask it, in plain words, to write an Expert Advisor, find a compile error, or explain code you do not understand. This guide shows how to turn it on, what it is good at, and where it can still cost you money if you trust it too much.
What the MetaEditor AI assistant is
MetaQuotes added a first AI coding assistant to MetaEditor in build 3800 (June 2023). It was based on OpenAI models.
In build 6060 (July 2026) it became a much bigger tool. The release notes call it a "full-fledged development assistant". It can:
- generate new MQL5 programs;
- analyze existing code, find errors and suggest fixes;
- explain complex algorithms;
- help with refactoring, for example converting an MQL4 EA to MQL5.
The assistant is not just a chat box. MetaEditor exposes tools to it, such as compile_file, syntax_check, write_file and replace_text_in_file, according to the MetaTrader 5 help on AI capabilities. So it can edit your files and compile them, not only talk about them.
By default it runs on a free "MQL5 Lite" model. You can also connect your own key from other providers. The help names OpenAI, Anthropic, Gemini, DeepSeek and xAI, among others (configuration help).
How to turn it on
These steps come from the official release notes and help pages.
- Update MetaTrader 5. The full assistant arrived in build 6060, so use that build or newer.
- Sign in to your MQL5.community account. The help says you must be signed in to use the AI Assistant. All users get the free MQL5 Lite plan.
- Open Tools \ Options \ AI Assistant. MQL5.community is the default provider. To use another model, choose a provider, check the endpoint, paste your API key, click Refresh and pick a model.
- Set the permissions. On the same tab you choose whether the AI may trade, must ask for confirmation, or may not trade at all. You also set web access and whether it may run shell commands like PowerShell or Python. AI settings sync between the terminal and MetaEditor.
- Open the assistant in MetaEditor. Use the File menu, the toolbar, or the Navigator context menu. Then describe your task in plain language. Your past chats are kept in the Chats tab of the Navigator.
For a coding-only setup, the safest choice is to set trading to "no trading" or "confirmation". You do not need the AI to place orders to write code.
What it is good at
Explaining code
Bought an EA source, or found old code on your PC? Ask the assistant to explain the logic and weak points. The build 6060 notes list "explain an EA's logic and weaknesses" as an example request. MetaEditor Help also describes an Explain via AI Assistant command for selected code (MetaEditor Help).
Fixing compile errors
This is where it saves the most time. It has tools to compile a file and to edit it, so it can read the errors, change the code and compile again. For a beginner, a list of cryptic errors is often the biggest wall. Now you can ask "fix the compile errors in this file" and check what it changed.
Writing small functions
Small, clear jobs work best: a lot size function, a trailing stop, a spread filter, a time filter. The release notes say more detailed requests give more accurate results. So say exactly what inputs, outputs and rules you want.
Porting MQL4 to MQL5
Converting an MQL4 EA to MQL5 is one of the official example tasks. It is boring work for a human and a good fit for an AI, as long as you test the result.
Where it falls short for EAs
Code that compiles is not a strategy that makes money. The assistant can write an EA that builds with zero errors and still loses on every trade. It has no way to know if your idea has an edge.
Even when it starts a backtest for you, you still have to judge the test. Ask yourself:
- Was it tested on real ticks? Tests on generated ticks can look far better than live trading.
- Are costs included? Spread, commission, swap and slippage can turn a nice curve flat.
- Was it forward tested? A strategy tuned on past data must also work on data it has never seen, and then on a demo or small live account.
- Does it fit your account rules? Prop firm limits on daily loss and max drawdown can end an account even if the EA is profitable over a year. Run your numbers through our prop firm rule check.
We cover this question in Can ChatGPT write a profitable EA?. The short answer: AI writes code fast, but proof of profit still comes from testing.
If your EA worked for a while and then stopped, read Why do expert advisors stop working?
The official help says the same in its own words: review and verify AI results before you use them, because you are responsible for the outcome.
A 5-step safe workflow
- Write the rules first. Before you open the assistant, write your entry, exit, stop loss and position size rules in plain words. Vague prompts give vague EAs.
- Build in small pieces. Ask for one function at a time. Compile and read each piece before you add the next.
- Keep trading off. Set the AI trading permission to no trading or confirmation while you code. Work on a demo account.
- Test it properly. Run the Strategy Tester with real ticks and realistic costs. Read the numbers in the tester report yourself.
- Forward test before real money. Run it on a demo or a small account for a while. Compare live results with the backtest. Only then size up.
FAQ
Is the MetaEditor AI assistant free?
Yes, there is a free option. All users get the MQL5 Lite plan, and MQL5.community is the default provider (build 6060 notes). If you connect your own provider key, you use your own account and quotas with that provider.
Can I use Claude, GPT or Gemini instead of the default model?
Yes. In Tools \ Options \ AI Assistant you can pick another provider, add your API key and choose a model. The help lists OpenAI, Anthropic, Gemini, DeepSeek and xAI, among others.
Can the AI assistant tell me if my EA will be profitable?
No. It can write, fix and explain code. It cannot know if a strategy has an edge. That answer only comes from backtests on real ticks with real costs, and a forward test.