MT4 and MT5 automation
Expert Advisor Coding: 3 Ways to Automate Your Trading Strategy
An Expert Advisor (EA) is a program that trades for you in MetaTrader 4 or MetaTrader 5. There are three practical ways to get one: hire an MQL programmer, build it yourself with an AI assistant, or use software that already has popular strategies built in.
Which route fits you?
| Hire a programmer | Build it with AI | Ready-made software | |
|---|---|---|---|
| Coding skills needed | None | Basic (compile, read errors) | None |
| Time to first version | Days to weeks | Hours to days | Minutes |
| Custom rules | Any | Any, if you can describe them | Built-in strategies, adjustable settings |
| Best for | Unique or complex strategies | Simple strategies, tinkerers | Candlestick and indicator strategies |
Whichever route you take, test the EA in the MetaTrader Strategy Tester and on a demo account before it trades real money.
Route 1
Hire an MQL4 or MQL5 programmer
A good programmer turns your rules into a clean, tested EA. The quality of the result depends mostly on how clearly you describe the strategy.
What to put in your specification
- Platform: MT4 (MQL4), MT5 (MQL5) or both, and whether your account is hedging or netting.
- Entry rules: the exact indicator settings, candle conditions and timeframe.
- Exit rules: stop loss, take profit, trailing stop, break-even and opposite-signal exits.
- Money management: fixed lots, % risk per trade, maximum open trades.
- Filters: trading hours, days, spread limit, news pause.
- Symbols: one chart per symbol, or one EA trading many symbols.
Tips that save money and time
- Ask for a fixed price and delivery date before work starts.
- Ask for the source code (.mq4 or .mq5), not only the compiled file, so you can change it later.
- Agree on one or two rounds of fixes after you test it.
- Keep the first version simple, and add features once the core logic works.
I’ve built apps for the MetaTrader platform since 2009, and for custom EA and indicator projects I recommend Emet Trading Solutions:

Route 2
Build your EA with an AI assistant
AI assistants such as ChatGPT, Claude and Gemini can write MQL4 and MQL5 code. For simple strategies this is now the fastest way to a first working version.
- Write the same specification you would give a programmer. Vague prompts give vague code.
- Ask for code for one platform only, for example “MQL5 for MetaTrader 5, hedging account”.
- Paste the code into MetaEditor, compile it, and paste any errors back to the AI.
- Backtest it in the Strategy Tester with realistic spreads, then run it on a demo account for a few weeks.
- Ask the AI to explain each part of the code, so you know what it does before it trades.
Where AI-written EAs go wrong
- They mix MQL4 and MQL5 functions, so the code doesn’t compile.
- They ignore broker details such as minimum stop distance, order filling modes and netting accounts.
- They skip error handling, so a rejected order can stop the EA silently.
- A good backtest doesn’t mean the strategy is profitable. Over-fitted settings usually fail on live data.
Route 3
Use ready-made strategies: FxMagnetic
Many strategies people want coded are built on well-known candlestick patterns and indicators. FxMagnetic, my MetaTrader software, already has 50+ ready-made strategies of this kind, so you can test them without writing code.
- Strategy scanner: signals from candlestick patterns such as Hammer, Pinbar, Engulfing and Morning Star, plus RSI, MACD and more.
- Backtesting on the chart: see how a strategy performed on historical data before you trade it.
- Stop loss and take profit: find the levels that worked best for each strategy.
- Autotrader EA: places the trades automatically for the strategy you choose.
- Alerts: sound, popup, email and push notifications.
If your idea is “trade this pattern with this indicator filter”, try FxMagnetic first. If it’s a unique system, hire a programmer or build it with AI.
Protect your account from any EA
Even a well-tested EA can misbehave: a bug, a broker change or an unusual market can lead to a string of losses. Equity Sentry EA watches your equity and, at the level you set, closes all trades and disables all Expert Advisors on the terminal.
Running the same EA on several accounts? Local Trade Copier (LTC) by Algonexis Technologies copies trades from one MT4/MT5 account to others on the same PC or VPS.
Frequently asked questions
What is an Expert Advisor?
An Expert Advisor (EA) is a program for MetaTrader 4 or MetaTrader 5 that opens, manages and closes trades automatically, following rules written in MQL4 or MQL5.
How much does Expert Advisor coding cost?
It depends on how complex the strategy is. A simple indicator-based EA costs far less than one with many filters, money-management rules and multi-symbol logic. Ask for a fixed quote based on a written specification.
Can ChatGPT or Claude write an Expert Advisor?
Yes, AI tools can write working MQL4 and MQL5 code from a clear specification. You still need to compile it in MetaEditor, fix errors, backtest it and run it on a demo account before using real money.
Should I choose MQL4 or MQL5?
Write it for the platform your broker account uses. MQL4 runs only on MT4 and MQL5 only on MT5; code for one doesn’t run on the other without changes.
Do I need to code to automate a strategy?
Not always. If your strategy uses popular candlestick patterns or indicators such as RSI or MACD, software like FxMagnetic already has ready-made strategies with backtesting and an Autotrader EA.
