Can ChatGPT Actually Write an MT5 EA? I Tested It (With Code)

Can ChatGPT Actually Write an MT5 EA? I Tested It (With Code)

25 May 2026, 16:30
Diego Arribas Lopez
0
28

Search YouTube right now: "ChatGPT writes MT5 EA in 10 minutes." Hundreds of videos. Every one of them ends with the EA appearing on a chart. Almost none of them show what happens when you actually run the EA on a live account. So I did. This is the real result, with the real code, and the real reasons most of those tutorials are misleading you.

The question 8,000 traders search every month — and almost nobody answers honestly

The question "can ChatGPT write an MT5 EA" gets thousands of monthly searches on Google. Often paired with "with telegram integration" or "for free" or "automatically."

The implicit hope behind the search is: can I skip learning MQL5, get an AI to build my EA, and start trading?

The honest answer, after testing it properly with a live account: partially yes, but not in the way the tutorials promise.

I ran the experiment. I gave ChatGPT a clear prompt asking for a complete, working MT5 Expert Advisor. I copied the code into MetaEditor, compiled it, fixed the errors, ran it on a backtest, then on a demo, then on a small live account. Each step revealed something the YouTube version of this story conveniently skips.

If you've been thinking about doing this, save yourself the API costs and the broker headaches. Read this first.

The exact prompt I used

I asked ChatGPT (GPT-5.5 model) for a simple but realistic EA. The prompt was deliberate — specific enough to get usable code, generic enough that any trader could replicate the experiment:

"Write a complete MT5 Expert Advisor in MQL5 that trades EURUSD on M15. Entry rules: buy when RSI(14) crosses above 30 from oversold, sell when RSI crosses below 70 from overbought. Stop loss 30 pips, take profit 60 pips, fixed lot size 0.01. Include input parameters for risk %, magic number, and broker suffix support. Include OnTick() logic, OnInit() initialization, and proper position management. Provide compiling, ready-to-paste code."

That's a real EA spec — boring strategy, but a complete one. RSI mean-reversion is one of the most-tested ideas in retail trading. If ChatGPT can't get this right, it can't get anything more complex right.

Step 1: ChatGPT generates ~150 lines of MQL5

The output came in clean. Proper MQL5 structure: OnInit() , OnTick() , OnDeinit() . Includes for <Trade\Trade.mqh> . Input variables for risk percentage, lot size, magic number, broker suffix. RSI handle initialization, position checks, order execution via CTrade .

At first glance: looks great. Looks like the kind of EA you'd buy on MQL5 for $30.

Then I tried to compile it.

Step 2: Compile errors that reveal the real limitation

First compile attempt: 3 errors, 2 warnings.

Specifics:

  • An undeclared variable in the position-counting function
  • A wrong parameter type passed to iRSI (used a deprecated signature)
  • A missing semicolon in the order block
  • A warning about implicit conversion in lot size calculation
  • A warning about uninitialized return value in one of the helper functions

This is what every "ChatGPT writes EA" tutorial conveniently skips. The first compile is rarely clean. ChatGPT trained on a mix of MQL4 and MQL5 code, plus blog posts, plus Stack Overflow answers, plus forum threads — many of which contain outdated or wrong syntax. The model interpolates. Sometimes it interpolates correctly. Often it doesn't.

I went back to ChatGPT, pasted the errors, asked for fixes. Got fixes. Compiled again. Two more errors I hadn't seen before — the fix had introduced new bugs. Three rounds of debugging later, the EA compiled.

Time spent so far: about 35 minutes. Not the "10 minutes" the tutorials promise. And I already knew MQL5 syntax well enough to verify the fixes were correct. A trader without MQL5 knowledge would have been stuck at iteration 2.

Step 3: Backtest results, before and after the obvious bugs

The compiled EA ran on the strategy tester. EURUSD M15, 12 months of data, 99% modeling quality.

First backtest: EA traded twice in 12 months.

The reason: ChatGPT had set the RSI cross-detection logic in a way that required a very specific tick-by-tick condition almost never met in practice. The signal was triggering on candle close in the spec, but the implementation was checking the wrong array index — comparing the current value to itself rather than the previous value.

This is a subtle bug. The code looks correct. It compiles. It runs. It just barely ever trades.

Round 4 of debugging. Got the bug fixed. Backtest again: EA traded 87 times in 12 months. Result: net loss of 4.2%.

Honest assessment: that's not a disaster. RSI mean reversion on EURUSD M15 isn't a great strategy in modern markets — most of the easy edges in that approach were arbitraged out years ago. So a 4.2% loss over 12 months is roughly what you'd expect from an honest implementation of a weak strategy.

The lesson isn't "ChatGPT wrote a bad EA." The lesson is: ChatGPT wrote a correct implementation of a strategy that doesn't work, and then you ran it. The intelligence to catch that the strategy itself was the problem — not the code — is the part ChatGPT can't supply.

This is the gap I built Alpha Pulse AI to close.
Instead of asking AI to write the EA code, I built an EA where the AI makes the trade decisions. Different problem entirely.
See how Alpha Pulse AI is different

Step 4: Live test on a small account ($200)

I funded a $200 demo, then a $200 live cent account on RoboForex, just to see what happens with real spreads and real slippage.

What broke that didn't break in backtest:

  • Broker suffix handling. Symbol was "EURUSDz" on the live cent account. ChatGPT's "broker suffix support" code partially worked — it concatenated suffixes when explicitly typed but failed on automatic detection. Manual fix.
  • Spread on M15 mean reversion. The EA was paying 1.2 pips spread on each trade. The backtest assumed 0.5. Over 87 trades a year, that's a ~60 pip difference, which on this strategy means going from -4.2% to roughly -8%.
  • Slippage on stops. On M15 trades held for 6+ hours, gap risk over weekends produced 3 stop-outs that were 4-7 pips worse than the spec. None individually catastrophic; collectively material.
  • News volatility. The EA had no news filter. ChatGPT didn't add one because I didn't ask. The first NFP release after deployment hit the EA with a 14-pip slippage stop.

Total live result over 6 weeks: -9.4%. Worse than backtest. Expected.

Why this experiment doesn't make ChatGPT bad at coding

I want to be careful here, because the "ChatGPT can't do anything" reaction is as wrong as the "ChatGPT writes you an EA" hype.

What ChatGPT actually did well:

  • Generated structurally valid MQL5 code on the first try
  • Recovered from errors when given specific feedback
  • Followed the spec accurately — the EA does what I asked, even if what I asked was a weak strategy
  • Provided helpful comments and reasonable parameter defaults
  • Could probably handle 70-80% of basic EA scaffolding for someone with intermediate MQL5 knowledge

What ChatGPT genuinely cannot do:

  • Tell you whether the strategy you specified is profitable. It will write the code for any strategy you ask, including bad ones.
  • Anticipate live-account edge cases without explicit instruction. Spread, slippage, broker suffixes, news filters, weekend gaps — if you don't ask, you don't get.
  • Verify its own bugs. ChatGPT will confidently produce subtly wrong code (the array index bug in our test) and say it works.
  • Replace the trading expertise that determines whether the EA should exist in the first place.

The real test: 5 things to do if you still want to write an EA with ChatGPT

If after reading this you still want to use ChatGPT to build your EA — and that's a perfectly reasonable choice for learning purposes or for a specific edge you've already validated manually — these are the rules that will stop you from blowing up an account:

  1. Validate the strategy first, manually, on backtest. Before you ask for any code, prove the strategy is profitable using a manual backtest or a no-code tool. ChatGPT will faithfully implement bad ideas.
  2. Compile every iteration. Read every error. If ChatGPT gives you "don't worry about that warning," don't believe it. Warnings are usually warning you about something that will silently misbehave.
  3. Demand explicit handling of: spread, slippage, broker suffix, news pause, weekend close. Ask for all of these in the initial prompt. ChatGPT will not add them by default.
  4. Run a 6-week minimum on demo before live. Backtest doesn't capture broker behavior. Demo doesn't perfectly simulate live, but it's closer.
  5. Live test with money you can afford to lose entirely. Cent accounts exist for exactly this reason. $20 of real loss teaches you more about your EA than $0 of demo loss.

If you do all of these, you can produce a working learning EA. You probably won't produce a profitable one, because the strategy itself is the hard part, not the code.

The deeper question: should AI write your EA, or run your EA?

This is the part the YouTube tutorials systematically avoid, because the answer doesn't help them sell a course.

"AI writes my EA" sounds like the future. It actually isn't. Once the code is generated, the AI is gone. The EA running on your account is a static rule-based system, no smarter than any other RSI-cross EA written in 2009. The "AI" part of the story stopped contributing the moment the code compiled.

"AI runs my EA" is a different proposition entirely. Every decision that comes out of the EA — buy, sell, wait, what size, what stop — is generated by the model in response to current market context. The AI isn't gone. It's making decisions on every tick.

That's the design principle behind DoIt Alpha Pulse AI. The EA doesn't have hardcoded entry rules in MQL5. It has a structured prompt sent to an LLM (Opus, Gemini, GPT, Grok — your choice) that returns a decision in real time. The MQL5 layer just executes what the model says.

The difference matters because the markets that exist in 2026 are not the markets that existed in 2009. A static rule-based EA, no matter how cleanly coded, captures setups that worked when the rules were written. An LLM-driven EA can adapt to market context — when the regime shifts, the prompt context shifts, and the decisions adapt with it.

Want an EA where AI makes the actual decisions?

Not "AI wrote the code once." Real-time AI decisions on every signal. Bring your own API key. Swap models. Audit reasoning.

See DoIt Alpha Pulse AI →
Live Myfxbook · 179 verified trades · Compatible with Opus 4.7, Gemini 3.1, GPT-5.5, Grok

Related reads if you're going down this path

If this experiment was useful, these go deeper on different parts of the same problem:

FAQ

Can ChatGPT really write an MT5 EA?

Yes, ChatGPT can generate MQL5 code for an MT5 Expert Advisor. The compiled output is structurally valid most of the time. Whether the EA actually trades profitably depends entirely on the strategy you specified, not on ChatGPT's coding ability. Strategy is the hard part; code is the easy part.

How long does it take to get a compiling EA from ChatGPT?

In my test, about 35 minutes including 3 rounds of debugging compile errors. If you have no MQL5 knowledge, expect 1-2 hours per iteration because you can't easily verify the AI's fixes. If you know MQL5 well, ChatGPT is more like a fast typist than a senior coder.

Will ChatGPT's EA make money?

It depends entirely on the strategy you specified. ChatGPT will write whatever you ask. If you ask for a known-bad strategy, you'll get a faithful implementation of a known-bad strategy. The AI doesn't validate trading logic — it implements code.

What about ChatGPT MT5 EA with Telegram integration?

Same answer. ChatGPT can absolutely add a Telegram notification layer using the standard MT5 WebRequest function. The integration code works. Whether the EA's trades are worth telling Telegram about is the separate question. If the strategy loses money, Telegram just notifies you about your losses faster.

Is there a better approach than getting ChatGPT to write the code?

For most retail traders, yes: use AI for decisions instead of code. Tools like DoIt Alpha Pulse AI let an LLM make trade decisions in real time, with the EA structure already built and battle-tested. You skip the coding entirely and let the AI do what it's actually good at — contextual decision making — instead of what it's mediocre at — writing other code.

Can I use Claude or Gemini instead of ChatGPT to write the EA?

Yes. Claude (especially Opus 4.7) tends to produce cleaner first-iteration MQL5 than ChatGPT in my testing. Gemini is faster but more error-prone. None of them solve the strategy validation problem. The choice of model affects code quality; it doesn't affect trade outcomes.

What's the minimum experience level to use AI to write an EA safely?

Honestly: if you can't read MQL5 well enough to spot a wrong array index or a missing news filter, you're not ready to deploy AI-generated EA code on a live account. Use it for learning. Use a battle-tested EA for actual trading.

This experiment was conducted on real broker accounts (demo and live cent) with real money at stake on the live segment. The losses described are real. The conclusions reflect my actual experience and are not financial advice. Backtests were conducted with 99% modeling quality on Dukascopy data; results would differ on lower-quality tick data.

Building or buying an EA and want the next experiments first? The newsletter is where these tests get published before anywhere else: subscribe here.