Implementing Another Front-end: Asirikuy Systems Now Trading on MT5 using the F4 Framework

For the past year I have been talking extensively about the improvement of our programming Framework at Asirikuy and how these developments have opened the door to the easy porting of Asirikuy systems to other trading platforms besides Metatrader 4. Today I have the pleasure to talk about the implementation of a MT5 frontend for the F4 framework which allows us to run systems in the MT5 platforms without needing to recode any of our strategies. Through this post I will discuss some of the problems I faced when making this move – so that those of you moving code to MT5 have some hints – as well as some of the solutions I found to these issues. I will also mention some of the advantages of having this front-end and some of the problems of the MT5 platform (which are many and rather ugly).

Why did I take the time to code a front-end for MT5? Well there are many reasons why I wanted to take this step. First of all it is probable that within a few years we will have to move to MT5 and it is also true that MT5 has some additional characteristics and advantages over MT4 which we may at some point want to explore. Additionally I also wanted to create an example of how easy it is to make our F4 framework – which is based on an ANSI C DLL – work with other trading platforms. By having a front-end and a DLL structure we are able to get everything working properly on different platforms without fully re-coding our systems, we just need to code a front-end that passes data and executes orders with a part on the DLL that is in charge of the data processing for that particular platform.

In the case of the MT5 platforms the coding of the front-end was not very problematic overall as the MT4 front-end code could be used as a base. Nonetheless there were several parts that had issues, particularly with the passing of dynamic string arrays (which can be done on MT4) which you simply cannot do on MT5. The solution I found was to pass an array of arrays of characters instead that in practice has the same functionality as the array of strings. Another nightmare was the passing of the MqlRates structure to the DLL since this structure is different than in MT4 and it required some time to be able to properly declare it within the ANSI C DLL. The key in this case was to realise that the time structure for the MT5 implementation is actually 64 instead of 32 bit (something Metaquotes should include somewhere in their manual), something which was difficult to decipher on my own (I only tested this after a lot of time looking at the memory addresses).

Another important step of coding the MT5 front-end was to port the Orderwrapper I had created for NFA compatible trading on the MT4 front-end. Since MT5 handles a single positioning approach by design, it became clear that in order to trade several systems there was an immediate need for an order manager (because you need to control positions from separate systems virtually because everything in reality is consolidated as a single position per symbol). I tried an order manager that had been previously coded and published at the mql5 website, but this implementation was very problematic for me, especially because it didn’t avoid the use of the virtual order management within back-testing something that greatly slowed down any testing process (because it constantly wrote to text files). Overall I decided against the use of this implementation and ported my MT4 Order Wrapper. This changing of the code took some time but after getting acquainted with the MT5 classes it was a very easy thing to do.

After debugging and testing the OrderWrapper and front-end I finally managed to start testing of Asirikuy systems using MT5. As I said before one of my ideas was to use MT5 for its increased testing speed and the ability to carry out some types of tests that cannot be done on MT4 (such as more custom optimizations) but I was disappointed to discover that many of the things I wanted cannot be done. First of all the worst thing about the MT5 platform – at least for me – is that you cannot import your own historical data. Metaquotes forces you to use historical data downloaded from the broker you have used to open your MT5 demo/live account with, if the data you download is bad, then too bad for you. It seems like a completely draconian move – an almost dictatorial imposition – to force traders to use some historical data without the ability of importing their own. It is very simple to implement a csv importing facility that allows you to run tests on your own external historical data but it seems that Metaquotes believes people are too stupid to know what data to run their tests on. I am convinced that any third-party Forex trading software that came with a strong server side, implemented MQL4 backwards compatibility and strategy tester improvements – without all the stupid issues introduced by Metaquotes with MT5 – would be able to get a good slice of their market share. Metaquotes gets away with anything because no one competes with them, introduce some competition that is willing to introduce the features people want and they will be forced to do the same.

Speed was also a big disappointment when running MQL5. I definitely thought that my tests would be faster – as I had experienced before – but it came out to be the total opposite with the F4 framework. The problem is that the only “faster” testing is achieved when you do “every tick” tests using MQL5-only code, but once you move to the calling of a DLL you get much slower testing when compared with MT5, especially if you’re already doing very fast tests on MT4 using Open Price only simulations. The “Open price only” mode on MT5 is much slower than on MT4 and the calling of the DLL takes several seconds more than in the MT4 platform. I am unsure if this is because the MqlRates structure has more elements – and therefore parsing and array of mqlRates can take more time – or simply because the implementation of DLL calling in MT5 is sub-optimal.

Overall I can say that I am happy with this achievement as it simply opens up the possibility to use the MT5 platform without any need to recode our strategies (current or future ones) and it also shows one of the very big advantages of the F4 framework which is the ability to be able to port everything from one place to another without too much hassle. Right now however back-testing is useless because I cannot port my own historical data but I have a few tricks up my sleeve to solve this, by studying the memory structure of the MT5 history files (hcc format) I think I will be able to create an hcc from a csv in order to allow the historical importing of data (take that Metaquotes dictators ! ;o)).

This new front-end will be released to the Asirikuy community for further testing this week-end. Additionally any members who have coded their own systems using F4 will now be able to use them in MT5 using the new front-end, no hassle. If you would like to learn more about our programming frameworks and how you too can take advantage of this for the creation of your own systems please consider joining Asirikuy.com, a website filled with educational videos, trading systems, development and a sound, honest and transparent approach towards automated trading in general . I hope you enjoyed this article ! :o)

Print Friendly
You can leave a response, or trackback from your own site.

One Response to “Implementing Another Front-end: Asirikuy Systems Now Trading on MT5 using the F4 Framework”

  1. fxbootstraps says:

    Interesting article.
    That historical data thing is a real problem.

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!
Show Buttons
Hide Buttons