Here is another unit testing library: https://github.com/MQLLAB/MQLUNIT
However, these only ensure code correctness and are difficult to use for trading-specific testing.
Do you save each change to the EA code as a separate file? Or do you modify the same code back and forth each time?
hini #:
Here is another unit testing library: https://github.com/MQLLAB/MQLUNIT
However, these only ensure code correctness and are difficult to use for trading-specific testing.
Do you save each change to the EA code as a separate file? Or do you modify the same code back and forth each time?
Thanks for sharing. Unfortunately, that library seems to be MQL4 only. I stick with MQL5 exclusively these days but hopefully that could help someone!
I track my whole MQL5 directory as a monolithic git repository, and so if I make changes to a single EA I'd just save changes to the relevant file(s).
Using git means I have full version history. I create a tag for any release so I can easily go back to an earlier version if I need to.
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
How do others ensure their MQL5 code is functionally correctly?
Coming from a software engineering background, I feel quite limited in the software testing options available for this. I have mostly manually tested my MQL5 code to date; however, as it grows in complexity, this (and the financial nature of it) makes me quite uncomfortable.
I'll share my approach and would love to hear from others about how they approach this problem!
Unit testing
I can't really see how to incorporate unit testing or even how to write a test harness.
There are some examples in the standard library that are implemented as Scripts, and I guess this is workable. But it feels like there will be a lot of boilerplate we need to provide to use this approach.
I've also found this third-party library: https://www.mql5.com/en/code/33089
I was really hoping to find something standard though. Am I missing something?
End-to-end testing
This is where I'm focusing now. While I'd love good test coverage with unit tests, I've at least tried to catch if/when I accidentally break one of my Expert Advisors (EA).
My thought process is this.
While this won't tell me what has gone wrong, it does let me know if the behaviour of my EA has changed, and how (to a degree).
Here is an example for one of my EAs, comparing the same parameters for two versions (v1.05 and v1.06). I first had to manually run the strategy tester and export Open XML reports for each run. I wrote a small Python program to take those two reports, compare them, and provide a summary report in HTML.
It's crude, but it does force me to think through when the behaviour of my EAs change.
How do other people think about software testing and quality control?