top of page

How AI can predict the trade results before they happen

Updated: Jun 23, 2023

And how to leverage that inside a MT5 Expert Advisor without Python dependencies.

Trade prediction has long been a challenging task for traders and investors alike. With so many factors affecting the market, it's difficult to accurately predict outcomes and make informed decisions. However, recent advancements in artificial intelligence (AI) have introduced a breakthrough method that is changing the game of trade prediction. In this article, we'll explore how AI is revolutionizing the industry and the new method that traders are using to gain a competitive edge.

The AI-based method for trade prediction represents a significant breakthrough in the industry, with the potential to transform the way traders approach the market. Unlike traditional methods, which rely on historical data and trends, AI-based methods leverage cutting-edge algorithms and machine learning to analyze vast amounts of data in real-time. This allows traders to quickly identify patterns and make informed decisions based on current market conditions, rather than relying on outdated information. The result is a more accurate and efficient approach to trade prediction that can help traders maximize profits and minimize risk. By adopting this innovative method, traders can gain a competitive edge and stay ahead of the curve in a rapidly evolving industry.

The revolutionary Ai Trade Prediction concept

In recent years, machine learning has emerged as a powerful tool for predicting trade outcomes and gaining a competitive edge in the market. However, the accuracy and reliability of these models can be improved even further by incorporating a novel concept for AI-based trade prediction.

AI-based trade prediction refers to the process of labeling not only the data points themselves but also the predictions made by the underlying trading strategy model. This helps to identify the confidence level of the predictions and can help traders to better understand the accuracy of the model. By incorporating trade prediction into their trading strategies, traders can make more informed decisions based on the predictions made by the model and adjust their risk tolerance accordingly.

At our firm, we've been using meta-labelling for several months now, and the results have been impressive. By gaining a better understanding of the confidence levels of our predictions, we've been able to make more informed decisions about which trades to pursue and how much risk to take on. This has led to increased profitability and a more efficient use of our trading capital.

The main idea of the concept is that we have a working and eventually profitable EA using manually crafted trading logic. This can be an EA using MACD, or Price Action or what ever ideas out there. In any case, the EA will identify times when to open new trades. When executed in the backtest, the trades the EA triggers are analyzed and used to train the AI model. The trained AI model then works as an assistant to the main EA strategy and is used to confirm a trade before it is sent to the broker.

So in short, AI-based trade prediction leads to following benefits:

  • Improves accuracy of the original EA strategy

  • Reduces the risk of loosing trades

How to build and integrate the AI-based trade prediction into an Expert Advisor?

The workflow comprises three main steps:

1. Collecting data from the backtest trades executed by the original EA

2. Use the collected data to train the AI model

3. Integrate the trained AI model into MQL code

1. Collecting data from the backtests

We can integrate data collection to your EA with only a few simple lines of code:

#include "AI-Labelling.mqh"

And then, just before opening an order with OrderSend(...) inside the original EA we register the trade via

ai_labelling.register_trade(order_type, ...)

Then when closing the trade position we generate the AI labels via


Then, when running a backtest the AI data is generated and exported as a file, so the AI model can be trained.

2. Training AI

We used Python to train an AI model in a way, that it reduced the risk of losses of the trades before being sent to the broker. The images above show the distribution of several data points collected by the ai_labelling module.

The training process usually takes 1-2 days using several optimization criteria from Optuna.

3. Integrating AI

After building the AI model, it is exported as an *.mqh file, which can be simply inserted into our MQL EA via

#include "ai_model.mqh"

Before entering a position, we will ask the AI model for the outcome prediction:

prediction = ai_model.classify(...)

Depending on the prediction, we can now decide in the main EA code if we should enter the position or not.


The results presented below are of sample nature. Real performance may vary due to market uncertainty and overfitting. In any case, we strictly advise to validate the AI-EA for at least two months on a demo account in real time before putting it on a real money account.

Here are a few backtest equity curves we obtained for XAUUSD, EURUSD and GBPUSD.

Can these be real?

That's the 257 Million Question. 😃 After obtaining these results in February 2023, we ran all three EAs on live accounts for two months.

The validation indicated that:

  • EURUSD failed

  • GBPUSD and XAUUSD passed validation and turned out to be quite profitable.



Please note, that after the first validation phase XAUUSD was further improved and the drawdown was reduced significantly. The new version is today available as AI for Gold EA

Consider the showcased outcomes as merely the initial phase of this groundbreaking trading methodology. Evidently, the debut Expert Advisor of this kind, known as "AI for Gold," has garnered enthusiastic feedback and garnered gratitude for its unwavering dependability and impressive performance.

Should you desire to explore additional milestones, novel Expert Advisors, and exclusive analytical insights, I encourage you to subscribe to our newsletter.

For those who are already part of our esteemed membership, I invite you to witness the remarkable live performance of "AI for Gold." Prepare to be pleasantly astonished by what you see.

164 views0 comments

Recent Posts

See All
bottom of page