Skip to content

MetatraderWithPython

Open Trading edited this page Feb 24, 2016 · 4 revisions

Metatrader has been a great international success, putting into the hands of end-users the ability to do programmed trading, something that was only previously available to large trading houses. It has been widely adopted, provides a credible platform for Forex trading, and there are a huge number of "experts" and programs that have been developed for it.

However, Metatrader as a language is not without some significant drawbacks. The language is very rudimentary from the computer science point of view, and is a closed sole-source product. Very importantly for writing robust, well-tested and easily maintained code, it lacks proper error handling flow-of-control constructs, such as are found in Java, Python or Lisp. This leads to poor quality code, as can be seen by much of the MQL code in existence, including the code from the manufacturer, MetaQuotes. The poor nature of the language combines with the very poor coding practices of the community (e.g. not checking error codes and no documentation or testing) to create a very poor programming environment.

Fortunately, Metatrader can be extended by writing C-coded function libraries that are called from MQL. These are usually simple C-coded function calls, but it opens the possibility of calling any C-coded interpreted program, including an interpreted language such as Python. This is a very good solution to extending Metatrader, as Python is the premiere language for scientific computation, and is being very rapidly adopted by the financial community (Quants). Python has an excellent programing culture of unit and functional testing, and is state-of-the-art in computer science.

The aim of the OTMql4Py is to develop a bridge to Python that can be called from Metatrader, under Windows and Linux. This allows Metatrader to be used as a front-end, receiving market data and executing orders, but with all the important algorithmic work, database access or user-interface extensions done in Python. This allows for the important algorithmic code to be subjected to much more rigorous testing, and makes it much easier to maintain. The bridge can be also used to feed standard high-speed financial message buses to distributed applications (e.g. FITS or ZeroMq): see our OTMlq4Zmq project at https://github.com/OpenTrading/OTMql4Zmq and its usage by OpenTrader at https://github.com/OpenTrading/OpenTrader


Parent: Home