• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Trading Heroes

Forex Trading Education

  • About
  • Articles
  • Resources
  • Shop
  • Login

How to Build No-Code MT4 Expert Advisors with ChatGPT

Learn how to create EAs for MetaTrader 4 without knowing how to code. With the help of ChatGPT, you can create them fast and backtest them.

Home / Trading Software Tutorials / How to Build No-Code MT4 Expert Advisors with ChatGPT

Last updated: May 6, 2025
By Hugh Kimura

Artificial Intelligence is still in its early days and there are a lot of bugs to be worked out.

However, one area that I have found it tremendously useful is in the area of creating automated trading robots for trading platforms like MetaTrader 4.

So in this tutorial, I'll show you how I'm using ChatGPT to create custom MT4 EAs. This process can be very fast and for simple EAs, you don't even know how to code.

If you prefer the text version, it's provided below the video.

Tutorial Video

How to Create an EA with ChatGPT

All of these steps should be done in a demo account. 

Never use an EA with real money until you're absolutely sure that it's working properly. 

For Trading Heroes Readers Only: Click here to get a HUGE limited-time discount on Forex Tester

Step 1: Have a Trading Strategy

You can get a trading strategy from almost anywhere…books, websites, YouTube or something you just made up.

Ideally, you should have a trading strategy that you've already backtested.

But if you just want to go through the process to see how it works, then just use the example code in the section below.

Step 2: Describe it to ChatGPT

Ask it to create an EA for MT4.

Then explain the rules as clearly as you can to ChatGPT. Write as if you were writing to a friend.

It will generate the code that you need for MT4.

Copy this code from ChatGPT

Step 3: Copy and Paste the Code into MT4

Then open the MetaQuotes Language Editor via the tool bar at the top.

Click the New button to create a new EA.

Select Expert Advisor, give it a name, then leave the rest of the settings blank. Keep hitting the Next button until you get to the end of the wizard.

mql4 EA wizard

That will give you a blank EA template.

Click anywhere in the code, then use Control + A to select all of the text. Then hit Backspace to delete all of the default code, then Control + V on your keyboard to paste in the ChatGPT code.

Click on the Compile button to generate the EA.

Step 4: Check for Errors

If there are any errors or warnings in the code, go back and ask ChatGPT to fix them.

It will generate new code.

Repeat step 3 above to start using the new code.

Step 5: Add the EA to a Chart and Start Testing

Once all the errors and warnings are gone, then you're ready to start using the EA.

Go to the main MT4 screen and look for the EA in the Navigator window.

MT4 Navigator window

Click and drag your new EA onto the chart.

There should be the name of your EA in the upper right corner of the chart you added it to, next to a happy face.

If the face is sad, click on the AutoTrading button at the top to activate the EA. The happy face shows that the EA is activated.

Now test the EA to see if it's working properly.

Test all of the regular features AND try to “break” the EA by doing things that it might not expect. This will show you how robust it is and will give you confidence in it.

If you have any issues, go back to ChatGPT and work on fixing them.

This may take several tries, but keep at it.

Example Code

If you want to give this a try, here's the example code. Simply copy and paste this prompt into ChatGPT and it will generate the code for this EA.

Important: This is for educational purposes only and should NOT be used in live trading. It's only provided to help you understand how to EA creation process works. There's a very high probability that this strategy will lose money.

“Please create an Expert Advisor for MetaTrader 4 that executes these rules:

  1. Indicators

    • Short SMA: 2?period simple moving average of Close

    • Long SMA: 36?period simple moving average of Close

  2. Long Entry

    • Condition: Short SMA (2) > Long SMA (36)

    • AND price closes below the Short SMA

    • Action: Open a buy at the close of that bar

  3. Long Exit

    • Condition: price closes above the Short SMA

    • Action: Close the long

  4. Short Entry

    • Condition: Short SMA (2) < Long SMA (36)

    • AND price closes above the Short SMA

    • Action: Open a sell at the close of that bar

  5. Short Exit

    • Condition: price closes below the Short SMA

    • Action: Close the short

  6. Position Sizing & Settings

    • Fixed size: 0.1 lots per trade

    • No stop?loss, no take?profit, no trailing stops”

Words of Warning

Remember that this is just step 1 in the process of creating a fully or partially automated trading strategy.

If you backtested with AI, you really, really have to double check the results.

Even if you didn't, you still have to check that the code is doing what you expected.

AI can hallucinate, so you have to be extra sure that the EA is doing what you expected before you risk real money.

Never trade the EA live until you're absolutely sure that it's working properly. 

Final Tips

I hope that this tutorial will help you create you own tools that improve your trading results.

At the time that this is being written, backtesting with AI is not mature yet.

However, creating EAs for MT4 is very usable, so I would highly recommend learning how to do it.

Even if you never build an EA, you can also build very useful custom indicators that can help you spot trading opportunities and manage parts of your trades.

Have fun!

Related Articles

  • Visual Strategy Builder Review: Build EAs Without Coding
  • How to Create a No-Code, Automated 50-200 MA Crossover Strategy
  • How to Create an Automated No-Code Bollinger Bands Trading Strategy
  • Metatrader 5 iPhone App (Build 485) Review
  • How to Build a Multi-Monitor Trading Computer
  • Build Your Own Low-Cost MetaTrader Virtual Private Server (VPS)

Category: Trading Software Tutorials Tag: MetaTrader 4 Tutorials

About Hugh Kimura

Hi, I'm Hugh and I'm an independent trader. Before starting Trading Heroes in 2007, I used to work at the trading desk of a hedge fund, for one of the largest banks in the world and at an IBM Premier Business Partner.

Learn more about me here and read more of my articles here.

Primary Sidebar

Trading Guides

How to Backtest a Trading Strategy in Any Market

The Heroic Guide to Forex Hedging for Beginners

How to Figure Out Your Trader Personality Profile

The Forward Testing Guide for Beginners

How to Create a Precise Trading Plan (with PDF worksheet)

About Hugh Kimura

 About Hugh Kimura

Hi, I'm Hugh. I'm an independent Trader and I started Trading Heroes in 2007.

Before starting this site, I worked at the trading desk of a hedge fund, at one of the largest banks in the world, and at an IBM Premier Business Partner.

Learn more
FREE Forex Hedging Guide
Forex Hedging Guide
Learn how Forex Hedging really works.

Download Now

Footer

Company

  • Trading Courses and Education
  • Trading Blog
  • About
  • Contact
  • Beware of Imposters

Articles

  • Backtesting
  • Etheric Finance Podcast
  • Forward Testing
  • Funded Trader Programs
  • Podcast
  • Trader Life
  • Trading Psychology
  • Trading Software Tutorials
  • Trading Strategies

Community

  • YouTube
  • Flipboard
  • Twitter
  • Instagram
  • Facebook

Trading involves risk and can result in the loss of your investment. Invest at your own risk. Past performance does not guarantee future results. All information on this site is for informational purposes only and is not trading, investment, tax or health advice. The reader bears responsibility for his/her own investment research and decisions. Seek the advice of a qualified finance professional before making any investment and do your own research to understand all risks before investing or trading. TrueLiving Media LLC and Hugh Kimura accept no liability whatsoever for any direct or consequential loss arising from any use of this information. This site is reader supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate, we earn from qualifying purchases. You are more powerful than you know, keep expanding.

 

Copyright © 2007–2025 TrueLiving Media LLC | Terms | Privacy | Risk