
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi you could import the onnx model on mql5 after you are done.
Why are you using 3 sets ?
Hi,
Regarding importing the ONNX model into MQL5, from my understanding (and correct me if I'm wrong), transferring a model to MQL5 can be quite challenging and may lead to inefficiencies. This process might result in a loss of complexity and functionality that more advanced frameworks like Python can handle more gracefully.
As for using three datasets, I separate them into training, validation (including hyperparameter optimization), and final testing sets. This approach ensures that the model is trained on one dataset, validated and fine-tuned on another to prevent overfitting, and then tested on an entirely separate dataset to evaluate its performance objectively. Using three distinct sets helps maintain the integrity of the model evaluation and optimizes its generalization capabilities.
I chose Python because integrating with the MetaTrader API is straightforward, and Python also allows for easy interaction with external APIs, such as those for news data. Additionally, Python simplifies working with databases—I’m currently using an Oracle cloud database, but any database would work similarly. This flexibility and ease of integration make Python a more efficient choice for developing and deploying complex models. But that's only my opinion.
Have you been able to achieve any positive results with the models you’ve developed? I’d love to hear about your experiences and any insights you might have.
Best regards!
Hi,
Regarding importing the ONNX model into MQL5, from my understanding (and correct me if I'm wrong), transferring a model to MQL5 can be quite challenging and may lead to inefficiencies. This process might result in a loss of complexity and functionality that more advanced frameworks like Python can handle more gracefully.
As for using three datasets, I separate them into training, validation (including hyperparameter optimization), and final testing sets. This approach ensures that the model is trained on one dataset, validated and fine-tuned on another to prevent overfitting, and then tested on an entirely separate dataset to evaluate its performance objectively. Using three distinct sets helps maintain the integrity of the model evaluation and optimizes its generalization capabilities.
I chose Python because integrating with the MetaTrader API is straightforward, and Python also allows for easy interaction with external APIs, such as those for news data. Additionally, Python simplifies working with databases—I’m currently using an Oracle cloud database, but any database would work similarly. This flexibility and ease of integration make Python a more efficient choice for developing and deploying complex models. But that's only my opinion.
Have you been able to achieve any positive results with the models you’ve developed? I’d love to hear about your experiences and any insights you might have.
Best regards!
You could validate similarity by comparing the outputs [of the model] on the training set on python and mql5. If you find inconsistency it means the Onnx on this side is not up to speed yet.
Interesting , so you backprop with the training set and manage the learning rate with the 2nd set ?
You avoid accidental overfits this way i guess
You could validate similarity by comparing the outputs [of the model] on the training set on python and mql5. If you find inconsistency it means the Onnx on this side is not up to speed yet.
Interesting , so you backprop with the training set and manage the learning rate with the 2nd set ?
You avoid accidental overfits this way i guess
I could migrate my model to MQL5 and compare whether its behavior is the same or similar to my Python model. However, honestly, since I already have the model in Python, I don't see an advantage in migrating to MQL5. The main reason I found it easier to create the model using Python is because it has a more extensive library, but it might be possible to do everything directly in MQL5, although my research suggests otherwise.
Regarding the datasets, yes, the idea is to use different sets for training, validation, and final testing precisely to avoid overfitting. I use the training set to perform backpropagation and update the model's weights, while the second set (validation set) is used to monitor performance and adjust the learning rate as needed. This approach helps prevent overfitting and ensures that the learning rate is optimized based on the model's performance on unseen data.
Since I already trade the Dow Jones index manually, I'm training the model on three years of data (2019-2021). Validation and optimization will occur on two years of data (2022-2023), and the final test will be on one year (2024). The final test serves to confirm that the results after training and optimization remain consistent. Additionally, it's important to use the datasets in chronological order so that the final test takes place in the most recent period (2024), which is more current and more likely to represent the current state of the market.
The most challenging part (after having the entire structure ready) is deciding which agent, environment, model, actions, states, rewards, etc., to use in training the model. There are so many variables and parameters that it's difficult to find a combination that results in stable learning and consistently profitable outcomes. But I'm making progress.
Do you have any combinations that are working well for you?
I could migrate my model to MQL5 and compare whether its behavior is the same or similar to my Python model. However, honestly, since I already have the model in Python, I don't see an advantage in migrating to MQL5. The main reason I found it easier to create the model using Python is because it has a more extensive library, but it might be possible to do everything directly in MQL5, although my research suggests otherwise.
Regarding the datasets, yes, the idea is to use different sets for training, validation, and final testing precisely to avoid overfitting. I use the training set to perform backpropagation and update the model's weights, while the second set (validation set) is used to monitor performance and adjust the learning rate as needed. This approach helps prevent overfitting and ensures that the learning rate is optimized based on the model's performance on unseen data.
Since I already trade the Dow Jones index manually, I'm training the model on three years of data (2019-2021). Validation and optimization will occur on two years of data (2022-2023), and the final test will be on one year (2024). The final test serves to confirm that the results after training and optimization remain consistent. Additionally, it's important to use the datasets in chronological order so that the final test takes place in the most recent period (2024), which is more current and more likely to represent the current state of the market.
The most challenging part (after having the entire structure ready) is deciding which agent, environment, model, actions, states, rewards, etc., to use in training the model. There are so many variables and parameters that it's difficult to find a combination that results in stable learning and consistently profitable outcomes. But I'm making progress.
Do you have any combinations that are working well for you?
Yeah you could take 10 samples , run them in mql5 with the onnx and output the outputs of the network in a file.
then run the same 10 samples on python and output the outputs of the network in a file.
if the outputs match then mql's onnx is up to speed with what you have used in python.
Not with python's libraries for onnx but with what you have used in that model.
Forum on trading, automated trading systems and testing trading strategies
Better NN EA
Sergey Golubev, 2025.02.28 17:59
Neural Network in Practice: Sketching a Neuron
In the previous article Neural Network in Practice: Pseudoinverse (II), I discussed the importance of dedicated computational systems and the reasons behind their development. In this new article related to neural networks, we will delve deeper into the subject. Creating material for this stage is no simple task. Despite appearing straightforward, explaining something that often causes significant confusion can be quite challenging.
What will we cover at this stage? In this series, I aim to demonstrate how a neural network learns. So far, we have explored how a neural network establishes correlations between different data points.
Forum on trading, automated trading systems and testing trading strategies
Better NN EA
Sergey Golubev, 2025.03.11 06:53
Neural Networks in Trading: State Space Models
In recent times, the paradigm of adapting large models to new tasks has become increasingly widespread. These models are pre-trained on extensive datasets containing arbitrary raw data from a broad spectrum of domains, including text, images, audio, time series, and more.
State Space Models
Thank you for sharing this information! I've been using MLP and CNN on my models, but SSM seems really interesting. It's a bit trickier to implement because it's very new, but I'll test it!
I started playing around with SSM, based on the shared article. At first I was going for the Mamba approach, but I ran into some technical stuff that made me fall back to classic S4 instead. Honestly though, using State Space Models made a huge difference — really appreciate the information shared here.
Also gave PPO with RNN a try, just to see what would happen. But in my case, the RNN didn’t seem to help much — kinda felt redundant with SSM. So I ended up sticking with plain PPO, and it’s been working fine.
Now here’s the weird part: I’ve been experimenting with reinforcement learning using a bit of intentional data leakage. I know, sounds wrong — data leakage is supposed to be a big problem. But the idea was to let the model peek a little into the future during training, in a controlled way. Turns out it actually helps the model understand and converge faster. What’s cool is that when I validate it (no leakage, unseen data, clean setup), it still performs better than models trained the "proper" way.
Just thought I’d share. Curious if anyone else has played with stuff like this.