6 min read

Build Your Own GPT4 Powered MT5 Dev Environment

Make your Expert Advisor dev environment super effective and efficient by bringing the latest in AI-powered code development to your development.
Build Your Own GPT4 Powered MT5 Dev Environment
AI Powered Development Environment, from Lenoardo.ai

MetaTrader is one of the world's largest retail FOREX trading platforms, with an estimated market share of 83.8% in 2022. Countless brokers worldwide use it to expose Forex trading to their customers, and it's considered a go-to tool for getting into serious retail trading.

One of the features that retail traders love is the ability to build custom trading bots, known as Expert Advisors, straight onto the platform. Using their proprietary coding languages, MQL4 and MQL5, almost any aspect of a trader's style and preference can be automated and deployed straight onto the same terminal they use for their trading.

It's pretty cool.

The problem is that both MQL4 and MQL5 have an exceptionally challenging learning curve. While they retain the blazingly fast roots of their C++ derivation, they also inherit the sheer annoyance of managing

every

single

little

thing.

As a result, many traders with fantastic bot ideas get put off or have to invest tens of hours learning how to proceed.

I believe that this sucks, so I wanted to do something about it!


About the Series

Over the next few months, I'll publish articles and YouTube videos that you can use to build your very own MetaTrader 5 Expert Advisor. I'll be showing you everything you need to:

  • Develop your own Expert Advisor
  • Customize how your Expert Advisor trades
  • Customize your risk parameters
  • Get common indicators from MetaTrader 5
  • Add your expert advisor to your MetaTrader

All trading is at your own risk, and you should not consider any of what I write to be investment or trading advice. My goal is to educate and inform, not provide investment advice.


What You Need to Complete This Article

  1. A working version of MetaTrader 5
  2. A Windows PC
  3. A GitHub CoPilot Subscription

Ready, Set, Dev It

YouTube Version

If you prefer to see this article on YouTube, then check it out here:

YouTube video version of this blog post

GitHub CoPilot

To bring the AI smarts to your MT5 EA Dev Environment, we'll be using GitHub CoPilot. GitHub CoPilot (not to be confused with the Microsoft CoPilot product) is a super powerful and super useful code assistant that will turbocharge your code writing. Even better, adding it to your dev environment is incredibly easy.

Use the link below to sign up for it. At the time of writing they are offering a free trial. Also, I get no kickbacks or referrals from this.

Visual Studio Code

If you're looking for a great Integrated Development Environment (known as an IDE), then check out Visual Studio Code. Known as VS Code, this great program is free, open-source, and exceptionally powerful. It truly makes your dev life awesome.

It's pretty straightforward to install and offers versions suitable for all major operating systems. Use the link below to download it.

MQL Tools

One of VS Code's superpowers is the use of extensions. Extensions allow VS Code functionality to be extended in new and cool ways by customizing aspects of the IDE to suit various languages, approaches, or even design choices.

The first extension we will be installing is a game-changer. It completely upgrades the development experience for building Expert Advisors, making it faster, easier and more accurate. When we combine it with the power of GitHub Copilot later in this episode, the difference is like night and day. Suddenly you have access to:

  • Intelligent code completion
  • Effective variable tracking
  • Effective syntax checking

If you want to read more about MQL Tools, check out the link below.

How to Add MQL Tools to Your VS Code

To this, follow these steps:

  1. Open VS Code
  2. Navigate to 'Extensions'
  3. Search for 'MQL Tools'
  4. Install

Here's gif of that in action:

Installing MQL Tools on VS Code

How to Update MQL Tools Settings for VS Code

The configuration of MQL Tools can be quite a challenge - so I hope this article saves you a few hours ❤️

Here's the steps.

Find MetaEditor64.exe

MQL Tools works by overlaying the compiler for MQL with the intelligent code completion of VS Code. Therefore, your first major step is to ensure it knows where the compiler is for MT5. This is called MetaEditor64.exe

You can find this in the executable filepath for your version of MetaTrader 5. For instance, I use an IC Markets version, so mine is located at: C:\Program Files\ICMarkets - MEtaTrader 5\MetaEditor64.exe

Add MetaEditor64.exe filepath to MQL Tools Settings

Next, you need to point MQL Tools to your MetaEditor64.exe Do this by:

  1. On MQL Tools settings page, click the gear icon
  2. Select 'Extension Settings'
  3. Scroll to Mql_tools.Metaeditor: Metaeditor5 Dir
  4. Paste the details into the text box

Here's a gif:

How to add MetaEditor64.exe to MQL Tools

Open the Right File Path

One of the weird gotcha's for MQL Tools is it's requirement to be opened to the 'right' filepath. There's probably a super good reason for this - I don't know it so I can't explain it 😆

Anyways, for whatever reason, you need to find the Terminal folder. Typically this will be located in the filepath C:/Users/<your_username>/AppData/Roaming/MetaQuotes/Terminal

Once you are there, follow these steps:

  1. In the list of folders that appears, ignore the folders 'Common', 'Community', or 'Help'
  2. Find the folders that have a long, somewhat random mix of capitalized letters and numbers. For instance 1DAFD9A7C67DC84FE37EAA1FC1E5CF75
  3. If you have multiple different folders like this, find the one that has a folder called MT5 in it. If you have multiple MT5's then find the one that corresponds with the version of MT5 you are using.
  4. Open this folder with your VS Code

Update VS Code settings

Now you need to update your VS Code settings to let it know how to 'handle' .mq5 files.

This is handled in your settings.json

settings.json is located in a folder called .vscode which can be found in your VS Code. If it doesn't exist, then create both the folder and settings.json

In this settings file, add the following code:

{
    "C_Cpp.default.forcedInclude": [
        "c:\\Users\\james\\.vscode\\extensions\\l-i-v.mql-tools-2.1.0\\data\\mql5_en.mqh" <- This should only change the name
    ],
    "C_Cpp.default.includePath": [
        "${workspaceFolder}/**",
        "${workspaceFolder}/Include"
    ],
    "C_Cpp.default.compilerPath": "C:\\Program Files\\ICMarkets - MetaTrader 5\\MetaEditor64.exe", <- This should be the same as the extension settings
    "C_Cpp.default.intelliSenseMode": "gcc-x64",
    "C_Cpp.errorSquiggles": "disabled",
    "C_Cpp.autocompleteAddParentheses": true,
    "files.exclude": {
        "**/*.ex4": true,
        "**/*.ex5": true,
        "**/*_@!!@.mq4": true,
        "**/*_@!!@.mq5": true,
        "**/*_@!!@.mqh": true
    },
    "files.associations": {
        "*.mqh": "cpp",
        "*.mq4": "cpp",
        "*.mq5": "cpp"
    }
}

Save the file and boom - you've got a flipping awesome IDE connected to your MT5

Unleash AI on EA Dev Environment

Let's finish up by unleashing the power of GitHub CoPilot on your dev environment.

Head back to your extensions list and add the following:

  1. GitHub Copilot
  2. GitHub Copilot Chat

You can read more about them here:

Finally, if you haven't already, you'll need to sign in to your GitHub account to activate these extensions.


Wrapping Up

Great work on getting your AI powered MT5 EA dev environment set up! Super cool!

In my next article, I'll be showing you how to get started building your own Expert Advisor, so feel free to check it out.

About Me

If you want to check out more of my work and content, then here's a few links:

  1. YouTube Channel
  2. TradeOxy Market Analysis Platform
  3. LinkedIn