How I Use Claude to Build Expert Advisors Faster (A Developer's Guide)
As MQL5 developers, our most valuable asset is time. We all have countless strategy ideas, but turning an idea into a robust, testable Expert Advisor takes hours. You have to write the boilerplate, manage indicator handles, set up inputs, and structure the trading logic. It's a long process.
For years, I did this all by hand. But recently, Large Language Models (LLMs) like Claude have completely changed my development workflow. I don't use them to "find a profitable strategy"—that's still our job. I use them as an incredibly fast, 24/7 junior developer.
Today, I want to share my exact workflow for using an AI like Claude to build a new EA from scratch. It doesn't replace you, the developer; it accelerates you.
What is Claude (and Why is it Good for MQL5)?
Claude is a conversational AI assistant. Its key strength is understanding context and plain-English instructions and translating them into structured code. While MQL5 is a specific, C++-like language, Claude has ingested enough documentation and code examples to be surprisingly fluent in it.
It's exceptionally good at:
- Writing "boilerplate" code ( OnInit , OnDeinit , OnTick structures).
- Creating all the input variables from a simple list.
- Scaffolding complex logic (e.g., "if this EMA crosses, and RSI is over 50, and it's a new bar...").
- Adding comments and formatting code to be readable.
My 4-Step Workflow: From Idea to EA
I don't just say, "build me an EA." That fails. You must act as a project manager. Here is my 4-step process.
Step 1: The "Master Prompt" - Defining the Strategy
This is the most important part. "Garbage in, garbage out." The quality of your EA depends 100% on the quality of your prompt. I write a detailed "brief" for the AI.
A good prompt includes:
- The Core Logic: "Check for trades on the OnTick function, but only execute on a new bar ( IsNewBar() )."
- Entry Conditions: "A BUY signal occurs when: 1. The 9-period EMA (applied to PRICE_CLOSE) crosses above the 21-period EMA. 2. The RSI (14-period) is above 50."
- Exit Conditions: "Use a Stop Loss and Take Profit. Do not use a trailing stop."
- User Inputs: "Create input variables for: MagicNumber, Lots, StopLossPips, TakeProfitPips, EMA_Fast_Period, EMA_Slow_Period, RSI_Period, RSI_Level."
- Risk Management: "Ensure the EA only opens one position at a time for this MagicNumber ."
- Code Standards: "Please use clean, well-commented MQL5 code. Include the CTrade library. Make sure all indicator handles are properly created in OnInit and released in OnDeinit ."
<!-- PSEUDO-CODE: Example Prompt Snippet --> "Hi Claude, please create an MQL5 EA with these rules: ... // --- Inputs --- input int MagicNumber = 10001; input double Lots = 0.01; input int StopLossPips = 500; input int TakeProfitPips = 1000; input int FastEMA = 9; input int SlowEMA = 21; // --- Entry Logic (OnTick/NewBar) --- 1. Check for a new bar. 2. Get the EMA(FastEMA) value for the [1] bar. 3. Get the EMA(SlowEMA) value for the [1] bar. 4. Get the RSI(14) value for the [1] bar. 5. IF (FastEMA > SlowEMA) AND (RSI > 50) AND (PositionsTotal()==0): trade.Buy(Lots, _Symbol, ...); ... "
Step 2: Generation and First-Pass Review
Claude will generate the full .mq5 file. I copy this directly into MetaEditor. My job now is to act as the "Senior Developer." I don't trust the code blindly; I review it.
I check for:
- Did it create all the indicator handles in OnInit ?
- Did it use ArraySetAsSeries on the buffers?
- Is the logic in OnTick correct? (e.g., did it use [1] for the previous bar as requested?)
- Did it release handles in OnDeinit ?
Step 3: Refining and Debugging (The Human Touch)
The AI almost *always* makes small mistakes. For example, it might forget to check the CopyBuffer return value, or it might miscalculate pips vs. points. This is where *my* expertise is essential.
I compile the code, read the errors, and either fix them myself or tell Claude: "You got this error: 'XYZ'. Please fix the code." This refinement loop is incredibly fast—what used to take me hours of typing now takes minutes of reviewing.
Step 4: Backtesting and Optimization
Once the EA compiles and runs, the AI's job is done. The rest is on me. I move to the Strategy Tester to verify the logic, test different inputs, and see if the core strategy idea has any merit.
AI for Building vs. AI for Trading
This workflow is a game-changer for accelerating development. It lets me test 5-10 new ideas in the time it used to take me to build one. It handles the "boring" parts, so I can focus on the *strategy*.
However, this is just "AI for Building." The next evolution, which I've been focused on, is "AI for Trading."
Instead of just using an AI to write the code, what if the EA used an AI *live* to make its decisions? This is exactly what my new Ratio X Gold ML (ONNX) EA is designed to do. It uses a pre-trained neural network (an ONNX model) that I trained on massive amounts of data to find predictive patterns.
It's the ultimate "Hybrid" system:
- A Machine Learning model provides the core predictive signal.
- My battle-tested "common sense" confluence filters (MTF EMAs, RSI, ADX, Spread) validate that signal.
It's the best of both worlds: pure data-driven prediction combined with robust, logical risk management.
Pre-Release Announcement: Ratio X Gold ML
I am doing a special, quiet pre-release of this EA for my MQL5 community friends before the official launch.
If you are interested in this "Hybrid AI" trading approach and want to be one of the first to use the Ratio X Gold ML, here's what to do:
1. Add me as a Friend on MQL5.
2. Keep an eye on my MQL5 wall.
I will be posting it on my wall first with a special introductory price only for those who are following me. This is my most advanced EA to date, and I'm excited to share it with a serious group of traders first.


