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
For added context, in the book MQL5 Programming for Traders, the author @Stanislav Korotky, dedicated an entire section on Testing and optimization of Expert Advisors.
In the PDF version that is 112 pages (A4 format). That should give you an ideia, why it is not so easy to give you a simple and objective answer about the Strategy Tester.
Dear support team,
I hope this email finds you well!
In case I want to build AI systems by using Python, which is the only option, would I be able to have the Python file communicating with a MQL5 file? Or it is advisable to build all the trading robot system in the same programming language?
I appreciate your time.
Best Regards,
João Valério
Dear Support Team,
I hope this message finds you well.
My team and I are in the process of migrating a strategy to your platform and have some questions regarding the reliability of the MT5 backtesting tool.
We are currently using data from AMP, which includes bid, ask, volume, and last price per tick. From my understanding, this represents the highest level of market depth available. Can you confirm if this is correct?
Additionally, could you recommend any resources or articles that explain how backtesting works in detail, particularly in relation to how closely backtest results compare to live trading outcomes?
Personally, I define backtesting as a market replay with real full depth market (including the 100% of transactions).
Thank you for your time and assistance.
Best regards,
João Valério
You can import ONNX models in mql5 if you are referring to neural networks
So you can do your "edge discovery" in pytorch/python/tensorflow and then use mql5 to facilitate it's trading
-If your AI is aimed toward managing the trades then you wont need pytorch at all . The tester is a better equipped environment to "evolve" the management aspect.
Thank you for the help!
I've read and explored the backtesting tool from MT5. I'll describe a scenario in order to help.
Strategy: Let's consider an ATM strategy working with limit orders. This strategy does around 30 trades per day in a single direction, in which the entry can be at any time of the day. I would consider it a medium-frequency algorithm.
Data: Data from AMP brokerage, which includes bid, ask, volume, and last price per tick.
Backtesting details:
Symbol: Nasdaq futures M1.
Modelling: Every tick based on real ticks.
Date: Last year.
Forward: No.
Delays: 125 ms (last ping to your server is 125.98 ms).
Deposit: 100000 USD.
Leverage: 1:1.
Optimization: Disabled.
I have 2 questions for this scenario:
1. We are currently using data from AMP, which includes bid, ask, volume, and last price per tick. From my understanding, this represents the highest level of market depth available. Can you confirm if this is correct?
2. I believe this scenario is as close to real as possible, but please correct me if I’m wrong. Given this, should I expect results similar to those of a live simulation? Are there any resources from the MT5 team that demonstrate the effectiveness of the backtesting tool? I came across these videos as examples: https://www.youtube.com/watch?v=rwVih5HGmxw and https://www.youtube.com/watch?v=h6FqPYTJNQc. Can I expect the same level of accuracy in the backtesting results?
Best Regards,
João Valério
It is impossible to distil in a fee lines all the ins and outs and intricacies of how to use the Strategy Tester. That is why there is documentation for you to read and apply. That is why there is a dedicated book to help programmers understand the documentation more easily with practical examples.
The reliability of the Strategy Tester is highly dependant on the the coder's skill and experience, both in programming, in trading and the use of the Strategy Tester. It will be impossible for you to gain that knowledge and experience in a few lines of text, or few days of experimentation. It takes time and dedication.
The Strategy Tester is a tool, just like a chisel and hammer are tools in the hands of a sculpture. The master will be able to sculpt wonderful pieces of art, while a the novice will produce junk, both with the exact same tools.
The same applies here. The Strategy Tester is only as good as the person wielding it. So, read the documentation, apply the knowledge, test, study, adjust, repeat.
As you progress, ask specific questions that can be answered objectively and simply. Progress and gain the skill and experience to master the Strategy Tester.
Also, take some time to search through the Articles section. Some are outdated and some more recent, but there is valuable information in there that should help you out as well.
Please note that you do not need to separately download AMP data to use the Strategy Tester. Simply connect to an account with AMP, and MetaTrader will automatically download, collate and process the necessary tick and OHLC bar data for testing.
Doing so, will also have the correct contract specifications, commission calculations, and other account details, thus facilitating your testing and offering more realistic results.
Got it! Thank you for the help!
You can import ONNX models in mql5 if you are referring to neural networks
So you can do your "edge discovery" in pytorch/python/tensorflow and then use mql5 to facilitate it's trading
-If your AI is aimed toward managing the trades then you wont need pytorch at all . The tester is a better equipped environment to "evolve" the management aspect.
Please note that you do not need to separately download AMP data to use the Strategy Tester. Simply connect to an account with AMP, and MetaTrader will automatically download, collate and process the necessary tick and OHLC bar data for testing.
Doing so, will also have the correct contract specifications, commission calculations, and other account details, thus facilitating your testing and offering more realistic results.
I appreciate the help! I believe this is exactly what I did.
In the following link: Testing Limitations, it is mentioned that:
"The tester compares the tick data to the minute bar parameters: a tick should not exceed the bar's High/Low levels, also initial and final ticks should coincide with the bar's Open/Close prices. The volume is compared as well. If a mismatch is detected, all ticks corresponding to this minute bar are discarded. Generated ticks are used instead (like in the 'Every tick' mode)."
If my tick data only contains bid, ask, last, and volume, where do these 'minute bar parameters' come from? Initially, I thought these parameters were extrapolated from the provided tick data. However, if this were the case, the comparison would seem redundant, as the ticks would naturally align with the minute bar values since they were derived from the same data.
Could you please clarify this process for me?
As long as you choose the "Every tick based on real ticks" modelling, than that will be the highest level of simulated testing.
As for the "market depth" or "order book information", I have never used it, so I am unsure how well it works in the Strategy Tester. There may be limitations. Maybe someone else can comment on that, but if your strategy is not dependant on processing order book information (MqlBookInfo), then there re is no need to worry about.
Yes, it will be the closest to the real live environment, but there are obviously limitations, because there are aspects that simply cannot be simulated. For example, the high network latency due to high volatility of high impact news. Other aspects that are not simulated, is for example, time diferences during daylight-savings changes.
So, as I have stated before, it all depends on the quality and skill of the programmer of the EA and the wielding of the Strategy Tester, and obviously the trading knowledge and expertise that went into the strategy and EA logic.
I appreciate the help! I believe this is exactly what I did.
In the following link: Testing Limitations, it is mentioned that:
"The tester compares the tick data to the minute bar parameters: a tick should not exceed the bar's High/Low levels, also initial and final ticks should coincide with the bar's Open/Close prices. The volume is compared as well. If a mismatch is detected, all ticks corresponding to this minute bar are discarded. Generated ticks are used instead (like in the 'Every tick' mode)."
If my tick data only contains bid, ask, last, and volume, where do these 'minute bar parameters' come from? Initially, I thought these parameters were extrapolated from the provided tick data. However, if this were the case, the comparison would seem redundant, as the ticks would naturally align with the minute bar values since they were derived from the same data.
Could you please clarify this process for me?
MetaTrader has separate data files for tick data and OHLC bar data, and it is collected from the broker separately.
So, if for some reason, the broker produced the data in such way that there is a discrepancy between the OHLC bar data and the tick data, then the tester will use generated or simulated ticks instead of the real ticks.
Personally, I would have preferred that it rebuild the OHLC data based on the tick data, or at least gave us the option, but unfortunately MetaQuotes opted for a different approach.
Understood. I appreciate the help!
MetaTrader has separate data files for tick data and OHLC bar data, and it is collected from the broker separately.
So, if for some reason, the broker produced the data in such way that there is a discrepancy between the OHLC bar data and the tick data, then the tester will use generated or simulated ticks instead of the real ticks.
Personally, I would have preferred that it rebuild the OHLC data based on the tick data, or at least gave us the option, but unfortunately MetaQuotes opted for a different approach.
I appreciate the help.
Point 2: Understood.
Point 1: How can a trading strategy avoid dependency on book information / DOM and still provide realiable results?
I believe, in Nasdaq Futures, the maximum depth available is limited to bid, ask, last price, and volume per tick. DOM (Depth of Market) or book information provides a snapshot of the supply and demand for liquid, tradable assets (such as contracts in futures markets). This data is crucial for effective backtesting. Without it, you cannot accurately simulate supply and demand dynamics throughout different periods of the trading day, which would result in unrealistic outcomes.
For example, how could a strategy tester know that I would be able to sell a specific contract at a price of 20,000 without knowing the available volume? It simply cannot be done accurately without such information.
Given this, I need to verify whether the strategy tester is indeed using DOM/book data during backtesting. Do you know someone who could help on this matter or should I wait for a possible answer?
Best Regards,
João Valério
As long as you choose the "Every tick based on real ticks" modelling, than that will be the highest level of simulated testing.
As for the "market depth" or "order book information", I have never used it, so I am unsure how well it works in the Strategy Tester. There may be limitations. Maybe someone else can comment on that, but if your strategy is not dependant on processing order book information (MqlBookInfo), then there re is no need to worry about.
Yes, it will be the closest to the real live environment, but there are obviously limitations, because there are aspects that simply cannot be simulated. For example, the high network latency due to high volatility of high impact news. Other aspects that are not simulated, is for example, time diferences during daylight-savings changes.
So, as I have stated before, it all depends on the quality and skill of the programmer of the EA and the wielding of the Strategy Tester, and obviously the trading knowledge and expertise that went into the strategy and EA logic.