Back to Trading Styles & Strategy Development

Trading Styles & Strategy Development · Pro · 4 min

Building an EA with AI as your co-pilot

You can use an AI assistant to turn pseudocode into MQL5 code while keeping control: precise prompts, line-by-line review, compiling, tests and a demo phase.

Code in seconds

AI assistants can write working code in seconds, in many programming languages, including MQL5 for MetaTrader. For traders who never learned to program, that changes what is possible: turning written rules into an Expert Advisor no longer needs a developer.

It also creates a new risk. It has never been easier to run code you do not understand, on an account with real money. Used well, the assistant is a co-pilot. You still fly the plane.

You stay the pilot

Steps A workflow with an AI assistant: you write the pseudocode, the AI drafts the code, you review it line by line, you compile and test it in the strategy tester, then run a forward test on a demo account. 1 Pseudocode 2 AI drafts 3 You review 4 Compile + test 5 Demo test
  1. Start with your pseudocode. The assistant implements what you specify. Give it your exact rules, the platform (MetaTrader 5, MQL5), how size is calculated, where stops go and what happens when a position is already open.
  2. Let it draft the code, ideally in small parts: the setup check, the trigger, the order, the management.
  3. Review it against the pseudocode, line by line. Ask the assistant to explain any line you do not understand, and check the explanation against the MQL5 documentation.
  4. Compile and test. Run it in the strategy tester with realistic ticks and costs. Check single trades on the chart: did it enter and exit exactly where your rules say?
  5. Forward test on demo before any real money, as in the forward-testing lesson.

Keep a copy of every version and note what changed. When something goes wrong, you need to know which change caused it.

Delegate drafts, not decisions

Comparison Tasks to give an AI assistant: drafting code, explaining functions, suggesting tests and finding typos. Tasks to keep: the rules, risk and position size, the final review and the decision to go live. Let AI do Draft code Explain functions Suggest tests Find typos Keep for yourself The rules Risk and size Final review The go-live decision

The division of labor matters. An assistant is good at drafting, explaining and spotting typos. It is not responsible for your rules, your risk or the decision to go live.

AI-generated code can look convincing and still be wrong. Pearce and colleagues (2022) asked an AI code assistant to complete 89 security-relevant scenarios and found that about 40% of the 1,689 generated programs contained vulnerabilities. Trading code has its own failure modes: a lot size calculated in the wrong unit, a stop that is never sent, an order repeated on every tick. Each looks harmless in the code and expensive on the account.

Also remember what an assistant cannot do. Asked for "a profitable EA", it will produce code, not an edge.

Common mistakes

The takeaway

AI assistants can draft EA code from your pseudocode, but they make confident mistakes. You stay the pilot: review, compile, test and demo every line.

Check yourself

Quick quiz

4 questions. Instant feedback, nothing is saved.

  1. 1Tap the step where you check every line the AI wrote.

    Tap the chart.

    Steps Chart for the question: Tap the step where you check every line the AI wrote. 1 Pseudocode 2 AI drafts 3 You review 4 Compile + test 5 Demo test

    Code that compiles can still do the wrong thing. Reviewing it against your pseudocode is your job.

  2. 2What did a study of an AI code assistant by Pearce and colleagues (2022) find?

    Generated code can look correct and still be flawed. In trading code, a flaw can mean real losses.

  3. 3Which instruction is better for an AI assistant?

    An assistant can only implement what you specify. It cannot invent an edge.

  4. 4The AI says its code 'should work'. What comes next?

    Confidence is not evidence. Only tests show what the code actually does.

of 4 correct.

Sources

Back to Trading Styles & Strategy Development