What's new
GoGoPips

You can add your own resource without restriction.

ML0425 for XAUUSD

ML0425 for XAUUSD 1.0

Symbol
XAUUSD (only BUY)
Timeframe
H1

Machine Learning in Trading (AI)​

If you open articles on MQL5 about machine learning, you'll likely be amazed at how deeply algorithmic traders have advanced in this area. Hidden Markov models, deep neural networks, Gaussian processes, Bayesian optimization, clustering...
1752387772935.png

But why do we sometimes achieve worse results using sophisticated methods compared to a simple moving average-based EA?

Why Simple Linear Strategies Are Sometimes Better Than AI​

To understand this issue, let's look at a simplified example of how model training works in trading:
  1. We take data from various indicators (such as RSI, MACD, iVolume) and feed it to the model.
  2. Then we tell the model when it should enter a SELL or BUY position. The model trains, evaluates itself — and everything looks great.
But there are some problems. One of the key issues is:
  • A limited number of independent features (indicators).
In other fields like medicine or banking analytics, machine learning can achieve up to 99% accuracy because there are many features, and they’re often independent — like height, gender, weight, age, blood pressure, and hundreds more.

In trading, it's not nearly as rich. We only have three core parameters:
  • Price
  • Time
  • Volume
And that’s it! Every indicator is just a combination of these three.

Imagine trying to cook 100 different dishes using only potatoes, salt, and water — not a lot of variety, right?
That’s exactly what happens when you try to feed the model 100 indicators.

and no, we can't just feed the model raw, non-normalized price data — like 3269.09 — in its original form. Imagine you're trying to learn something based on specific examples, but after training, you never see the same example again, and every time you're presented with a thousand entirely unique, non-repeating cases.

That's exactly what the model experiences if you give it raw price values. This leads to 100% overfitting — the model will simply memorize each unique moment instead of learning any real patterns.


Let’s Build an ML-Based Expert Advisor and Compare It to a Simple One​

Let's create a machine learning-based expert advisor for trading the all-time favorite XAUUSD.

As a feature, we'll use a simple price Slope function:

1752387816936.png


We’ll call the first EA Model_#0. This model was trained on data from 2015 to 2025.

The backtest results of Model_0 show nearly perfect trading: minimal stop losses and logical trades, all packed into a tiny model under 0.1 MB in size.

1752387838343.png


Next, we create a second model (Model_1), trained on data from 2015 to 2024, and test how it behaves on unseen 2025 data.
Model_1 performs great during its training period, but as soon as it faces new data, its effectiveness drops significantly:
(the red marks are the learning area)

1752387858682.png


Interestingly, when we disable SELL trades, performance improves — likely due to the strong bullish trends in XAUUSD. Yes, it's been working for more than a year, but it's already less productive.
BUY only:

1752387877974.png


Now let’s compare this to a simple linear strategy (call it Stenvall), created and published in 2021, which hasn’t been updated since.
Despite its average results, this strategy delivers stable performance year after year.

1752387892154.png


ML-based expert advisors can show beautiful backtests and impressive short-term results, but they often lack consistency on future data. In contrast, linear strategies may even outperform their past results thanks to their simplicity and resilience to market changes.

Why does this happen?
This is a difficult philosophical question, why complex things are often worse than simple ones.
Can say:

  • Overfitting of complex models to historical data. Due to the lack of good features the model tries to catch even the tiniest patterns — ones that have no real predictive power.
  • Complex structural signals are often temporary in nature.
  • The resilience of simple strategies based on simple fundamental principles of the market, liquidity zones, support and resistance levels, and so on.
But I think these answers are unlikely to satisfy everyone 100%.

Conclusion​

Does this mean machine learning isn't suitable for trading? Of course not. The goal of this example was to show that ML isn’t some magic solution that can look at raw data and tell you where to buy and sell. ML is a powerful tool — but one that requires the right approach.

P.S.

Many important aspects — such as data normalization, labeling quality, or Feature Engineering — were left out of this article, since the main focus was on comparing simple vs. complex approaches.

There are many articles on MQL5 about ML, but they’re not always digestible for traders without a technical background. I just wanted to explain some complex topics in simple words, and I hope this article adds a bit of clarity.

The EA from the article is free to download and distribute.
Author
leontolstoy
Downloads
691
Views
2,326
First release
Last update
Rating
5.00 star(s) 7 ratings

Share this resource

Latest reviews

the best free bot
Upvote 0
I had done a backtest earlier and as far as i can see this EA's already surpassed majority of paid EA's in the market! tommorow i will test it live and see what will be the outcome but im sure it will be very good just like MAD TURTLE!
Upvote 0
Shows promise!!
Upvote 0
This is a very good EA. I have been using for about a month now on a live account and it's very profitable. Can't believe this is free. Well worth the download!!
Upvote 0
first 4 trades in profir+
Upvote 0
I'm excited to test all the EAs! I'll keep posting updates and sharing the different results. Thanks so much for all your hard work in building this.
leontolstoy
leontolstoy
Thanks for the feedback!
Upvote 0
Thx
Upvote 0
Top