Metaquotes MQL 5 - API
We moved our strategy prototype development to
backtrader. I decided to write an API for Metaquotes MQL5 based on ZeroMQ socket framework. Thanks to @ed-bartosh and @sandro-böhme for CCXT broker code examples.
This is first alfa release. The code is not stable yet but historical/live datas work already. Next week we will start strategy testing. So, I think that stable beta will be in a few weeks.
All ideas and improvements are welcome. I'll post updates here.
I have released stable beta
MQL5 JSON API. Most part of the documentation is also ready. See it on github.
Backtrader MQLbroker stable beta is almost ready too. Don't use alfa release of the broker. The code would not work because MQL side was refactored.
Nikolai last edited by
I have released
Backtrader-MQL5-APIstable beta. MQL5 has complex order management logic, so i have some headache implementing it to
backtrader. )) Only market orders working right now. It will take some time to finish pending orders.
self.positiondoesn't work too. Because of threading
nexthappens several times before position approval returns from MQL5. @backtrader Do you have any idea how to fix it? Thanks.
cgd last edited by
This is fantastic news, thank you so much! :)
New update of both repos.
MQL5 JSON APIis finished. Historical data load speed was optimized. I have to finish various features like:
- error handling docs
Reconnection and data uploading after reconnection were added to
Backtrader-MQL5-APIThe main goal for now is to finish pending orders management.
Hi, everyone. New update of both repos.
All goals in
Pending orders in
We will start production testing next week.
@Nikolai hi Nikolai,
is it possible to use MQL5-api for optimization?
does it work ?
Nikolai last edited by
What do you mean "for optimization"?
Yes, it works.
I mean is it possible to use this code to optimize an strategy in metatrader5?
@Nikolai I mean is it possible to use this code to optimize a strategy in "optimize mode" in metatrader5?
for example send sell/buy order from your python client code to metatrader5 in optimize mode? and if the answer is yes is it possible to handle this scenario in multi-core optimization mode in metatrader?
It is obviously not possible.
The code from Nikolai is a bridge to let something written in backtrader use MT5 as a data feed and as broker.
An optimization run in Metatrader runs agents which you select (and no, something developed in backtrader is not an agent). See the article and pictures.