darwinex / darwinexlabs Goto Github PK
View Code? Open in Web Editor NEWDatasets, tools and more from Darwinex Labs - Prop Investing Arm & Quant Team @ Darwinex
Home Page: https://www.darwinex.com
License: BSD 3-Clause "New" or "Revised" License
Datasets, tools and more from Darwinex Labs - Prop Investing Arm & Quant Team @ Darwinex
Home Page: https://www.darwinex.com
License: BSD 3-Clause "New" or "Revised" License
Hi! I faced with seven errors during compile's process of DWX_ZeroMQ_Server_v2.0.1_RC8.mq4 file in MT4. I believe that these errors are related to HTML comments, but I guess those are misleading errors! Is everybody faced with this problem too?
'' - single quote needed DWX_ZeroMQ_Server_v2.0.1_RC8.mq4 158 10
'`' - unknown symbol DWX_ZeroMQ_Server_v2.0.1_RC8.mq4 158 11
Complete.
ZeroMQ_MT4_R_Template.R freezes RStudio because of an issue related to stdin.
I was able to fix it like so:
while(TRUE){
content <- readLines(stdin(), n=1)
if(content=='ex'){
print(paste('End Command:',content))
break
}
Actually I had a fully functional version. But since two days, I'm not able to recreate it. It's totally strange.
In my opinion exceptions are crucial in the 'socket-land', keyword 'deadlocks'. So server and clients have to use an extensive amount of checks and exceptions. Connections, bindings and contexts have to be closed, terminated etc. decently. Otherwise any debugging is nothing less then hell.
Latest R/Win7/MT4
How to compare the previous bid with current bid by using zeromq python
DWX_ZeroMQ_Server_v2.0.1_RC8
I get a bunch of warnings...actually can't been overseen...
implicit conversion from 'number' to 'string' (multiple lines)
declaration of 'data' hides global declaration in file [...] Z85.mqh (multiple lines)
expression not boolean GlobalVariable.mqh (multiple lines)
By the way, is this server version for Python only?
I can't find any information, on how to handle the versions in regard to R.
And is it OK to use the old version because of its simple, easy to extend structur?
Thank you.
Complete.
Hi. I'm able to run other commands such as sending new orders but each time i subscribe to market data and then trying to get data i get an empty dict {}
:
>>> _zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_('EURUSD')
[KERNEL] Subscribed to EURUSD BID/ASK updates. See self._Market_Data_DB.
>>> _zmq._Market_Data_DB
[Output]
>>> {}
I use python 3.7
Please help!
Hello everyone,
So here is my problem, I am working on a web scraper to perform trades depending on information gathered on the internet.
However, when I try executing requests inside a python script, such as _zmq.DWX_MTX_GET_ALL_OPEN_TRADES() I get no answers from the server and cannot retrieve any information under _zmq._Market_Data_DB or _zmq._History_DB.
Moreover, if I try to open an order with zmq.DWX_MTX_NEW_TRADE(order) I get the Resource timeout.. please try again. error.
(MS VC++ is downloaded and up to date; verbose = True)
If using a python shell, however, I can pass orders that are received by MetaTrader4 and I am getting the expected output from other functions.
Therefore, this is leading me to believe that maybe there is a problem receiving responses from MetaTrader4 when using a script instead of a shell command. Any idea on how to fix this would be really appreciated.
Thank you.
Running python 3.9 on Windows 10, Using MetaTrader4 and coding in PyCharm
The two file "DWX_ZeroMQ_Server_v2.0.1_RC8.mq4" and "GlobalVariable.mq4" are showing error and warnings
The file "DWX_ZeroMQ_Server_v2.0.1_RC8.mq4" is showing 1 error
'&' - parameter passed as reference, variable expected DWX_ZeroMQ_Server_v2.0.1_RC8.mq4 205 27
while the file "GlobalVariable.mq4" is showing 4 errors and 2 warining
(!) expression not boolean GlobalVariable.mqh 42 78
(!) expression not boolean GlobalVariable.mqh 64 64
(-) '::' - unexpected token GlobalVariable.mqh 200 46
(-) 'create' - function not defined GlobalVariable.mqh 200 48
(-) '::' - unexpected token GlobalVariable.mqh 211 32
(-) 'create' - function not defined GlobalVariable.mqh 211 34
Note: The other include files loaded properly
Hi,
When I try to compile it, it gives me this issue:
"'&' - parameter passed as reference, variable expected DWX_ZeroMQ_Server_v2.0.1_RC8.mq4 206 27"
The error is on line 206, on the instruction "InterpretZmqMessage(&pushSocket, components);"
Thanks in advance
I followed the isntructions for installing the https://github.com/darwinex/DarwinexLabs/tree/master/tools/dwx_zeromq_connector but when I drag the DWX_ZeroMQ_Server_vX.Y.Z_RCx.mq4 to the chart I get:
cannot open file 'C:\Users\fo\AppData\Roaming\MetaQuotes\Terminal\E6734F6041F45FBC490D7BD7FB1CB8E3\MQL4\Experts\DWX_ZeroMQ_Server_v2.0.1_RC8.ex4' [2]
How I can solve this?
There is a missconception in the remote.send function. Request and answer will not work on the same socket.
good day
first off thank you for your contribution to this matter, unfortunately I am getting an error
File "zmq/backend/cython/socket.pyx", line 676, in zmq.backend.cython.socket.Socket.send
TypeError: unicode not allowed, use send_string
could you please help me
I am getting an Error with code 129 (Invalid Price). My python code is :
from DWX_ZeroMQ_Connector_v2_0_1_RC8 import DWX_ZeroMQ_Connector
_zmq = DWX_ZeroMQ_Connector()
_zmq._DWX_MTX_NEW_TRADE_()
I tried several days by changing EA code. But I could not resolve this.
Hi, How do you connect the zmq to MT5 EA
The choosen ports in DWX_ZeroMQ_Server_v2.0.1_RC8 don't work on my system while the former numbers out of the 5000-range do.
Win7
The python runs (sort of) but I get this error :
ValueError: DataFrame constructor not properly called!
Exception in thread AUDNZD_Trader: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\threading.py", line 916, in _bootstrap_inner self.run() File "C:\ProgramData\Anaconda3\lib\threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "Z:/Forex/testpath/coinflip.py", line 185, in _trader_ 10) File "Z:\Forex\testpath\lib\DWX_ZMQ_Reporting.py", line 55, in _get_open_trades_ index=_response['_trades'].keys()) File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\core\frame.py", line 422, in __init__ raise ValueError('DataFrame constructor not properly called!') ValueError: DataFrame constructor not properly called!
Full pastebin here https://pastebin.com/5504A05f
This is an example of the response data (using print statements:
_response= {'_action': 'OPEN_TRADES', '_trades': {96569338: {'_magic': 123456, '_symbol': 'GBPJPY', '_lots': 0.01, '_type': 1, '_open_price': 145.388, '_open_time': '2019.04.08 15:02:18', '_SL': 145.488, '_TP': 145.288, '_pnl': -0.46, '_comment': 'GBPJPY_Trader'}, 96569143: {'_magic': 123456, '_symbol': 'AUDNZD', '_lots': 0.01, '_type': 1, '_open_price': 1.05499, '_open_time': '2019.04.08 14:57:36', '_SL': 1.05599, '_TP': 1.05399, '_pnl': -0.14, '_comment': 'AUDNZD_Trader'}, 96569141: {'_magic': 123456, '_symbol': 'AUDUSD', '_lots': 0.01, '_type': 0, '_open_price': 0.71066, '_open_time': '2019.04.08 14:57:34', '_SL': 0.70966, '_TP': 0.71166, '_pnl': -0.03, '_comment': 'AUDUSD_Trader'}, 96569140: {'_magic': 123456, '_symbol': 'USDJPY', '_lots': 0.01, '_type': 1, '_open_price': 111.437, '_open_time': '2019.04.08 14:57:33', '_SL': 111.537, '_TP': 111.337, '_pnl': -0.26, '_comment': 'USDJPY_Trader'}, 96569139: {'_magic': 123456, '_symbol': 'GBPUSD', '_lots': 0.01, '_type': 1, '_open_price': 1.30538, '_open_time': '2019.04.08 14:57:32', '_SL': 1.30638, '_TP': 1.30438, '_pnl': 0.58, '_comment': 'GBPUSD_Trader'}, 96569130: {'_magic': 123456, '_symbol': 'EURUSD', '_lots': 0.01, '_type': 0, '_open_price': 1.12479, '_open_time': '2019.04.08 14:57:17', '_SL': 1.12379, '_TP': 1.12579, '_pnl': -0.28, '_comment': 'EURUSD_Trader'}, 96569107: {'_magic': 123456, '_symbol': 'EURCAD', '_lots': 0.01, '_type': 0, '_open_price': 1.50396, '_open_time': '2019.04.08 14:56:18', '_SL': 1.50296, '_TP': 1.50496, '_pnl': 0.1, '_comment': 'EURCAD_Trader'}, 96569106: {'_magic': 123456, '_symbol': 'NZDCHF', '_lots': 0.01, '_type': 0, '_open_price': 0.67343, '_open_time': '2019.04.08 14:56:17', '_SL': 0.67243, '_TP': 0.67443, '_pnl': 0.02, '_comment': 'NZDCHF_Trader'}}}
_response['_trades'].values()= dict_values([{'_magic': 123456, '_symbol': 'GBPJPY', '_lots': 0.01, '_type': 1, '_open_price': 145.388, '_open_time': '2019.04.08 15:02:18', '_SL': 145.488, '_TP': 145.288, '_pnl': -0.46, '_comment': 'GBPJPY_Trader'}, {'_magic': 123456, '_symbol': 'AUDNZD', '_lots': 0.01, '_type': 1, '_open_price': 1.05499, '_open_time': '2019.04.08 14:57:36', '_SL': 1.05599, '_TP': 1.05399, '_pnl': -0.14, '_comment': 'AUDNZD_Trader'}, {'_magic': 123456, '_symbol': 'AUDUSD', '_lots': 0.01, '_type': 0, '_open_price': 0.71066, '_open_time': '2019.04.08 14:57:34', '_SL': 0.70966, '_TP': 0.71166, '_pnl': -0.03, '_comment': 'AUDUSD_Trader'}, {'_magic': 123456, '_symbol': 'USDJPY', '_lots': 0.01, '_type': 1, '_open_price': 111.437, '_open_time': '2019.04.08 14:57:33', '_SL': 111.537, '_TP': 111.337, '_pnl': -0.26, '_comment': 'USDJPY_Trader'}, {'_magic': 123456, '_symbol': 'GBPUSD', '_lots': 0.01, '_type': 1, '_open_price': 1.30538, '_open_time': '2019.04.08 14:57:32', '_SL': 1.30638, '_TP': 1.30438, '_pnl': 0.58, '_comment': 'GBPUSD_Trader'}, {'_magic': 123456, '_symbol': 'EURUSD', '_lots': 0.01, '_type': 0, '_open_price': 1.12479, '_open_time': '2019.04.08 14:57:17', '_SL': 1.12379, '_TP': 1.12579, '_pnl': -0.28, '_comment': 'EURUSD_Trader'}, {'_magic': 123456, '_symbol': 'EURCAD', '_lots': 0.01, '_type': 0, '_open_price': 1.50396, '_open_time': '2019.04.08 14:56:18', '_SL': 1.50296, '_TP': 1.50496, '_pnl': 0.1, '_comment': 'EURCAD_Trader'}, {'_magic': 123456, '_symbol': 'NZDCHF', '_lots': 0.01, '_type': 0, '_open_price': 0.67343, '_open_time': '2019.04.08 14:56:17', '_SL': 0.67243, '_TP': 0.67443, '_pnl': 0.02, '_comment': 'NZDCHF_Trader'}])
_response['_trades'].keys()= dict_keys([96569338, 96569143, 96569141, 96569140, 96569139, 96569130, 96569107, 96569106])
DWX_ZMQ_Reporting():
`# -*- coding: utf-8 -*-
"""
DWX_ZMQ_Reporting.py
--
@author: Darwinex Labs (www.darwinex.com)
Copyright (c) 2019 onwards, Darwinex. All rights reserved.
Licensed under the BSD 3-Clause License, you may not use this file except
in compliance with the License.
You may obtain a copy of the License at:
https://opensource.org/licenses/BSD-3-Clause
"""
from pandas import DataFrame, to_datetime
from time import sleep
class DWX_ZMQ_Reporting():
def __init__(self, _zmq):
self._zmq = _zmq
##########################################################################
def _get_open_trades_(self, _trader='Trader_SYMBOL',
_delay=0.1, _wbreak=10):
# Reset data output
self._zmq._set_response_(None)
# Get open trades from MetaTrader
self._zmq._DWX_MTX_GET_ALL_OPEN_TRADES_()
# While loop start time reference
_ws = to_datetime('now')
# While data not received, sleep until timeout
while self._zmq._valid_response_('zmq') == False:
sleep(_delay)
if (to_datetime('now') - _ws).total_seconds() > (_delay * _wbreak):
break
# If data received, return DataFrame
if self._zmq._valid_response_('zmq'):
_response = self._zmq._get_response_()
if ('_trades' in _response.keys()
and len(_response['_trades']) > 0):
_df = DataFrame(data=_response['_trades'].values(),
index=_response['_trades'].keys())
return _df[_df['_comment'] == _trader]
# Default
return DataFrame()
##########################################################################
Hello,
I was trying to set this up. But when sending rquests longer then the RATES|GBPUSD command causes an error in ZeroMQ_MT4_EA_Template.mq4 and MetaTrader 4 crashes.
Hey
I need to get multiple symbol Ask/Bid data in same time
I can get this data separately but I can't get that altogether
please help me
Hi,
I created an 8GB RAM VM for this, which has the latest Windows 10 Enterprise , live MT4 and Python 3.7 32 bit (I suspect with 0mq there is no difference between python 32 bit and 64). The VM itself has given me no weirdness so far. With this new DWX I am getting 99% of the time problems, though they do not seem 100% reproducible. I got no messages at all in "Experts" once or twice, or I got just the Binding message, or I got pricings for a few ticks and then it was gone(not stopped or crashed, it just wasn't printing any more prices). Restarting the computer seems to take a long time to shut MT4 down, and on my current run I only got the Binding messages and decided to turn on the "Live trading" property of the EA, which seems to have crashed my MT4 (Not responding for 10 minutes or more).
Somewhere in the middle of all this the EA triggered Windows Firewall (do you want to allow...) to which I replied yes, of course. Sometimes turning the firewall off helps with such issues, but I also suspect the server could exit/crash more gracefully. I will probably try on Windows 7 later. From other comments it is clear previous versions run OK for some people, no comments yet on the new one.
Finally it is Friday and the ticks are few but not that few!
Thanks!
Hi,
I came across an issue making me very confused. When using the DWX_MTX_NEW_TRADE() to place an order: {'_action': 'OPEN', '_type': 1, '_symbol': 'USDJPY', '_price': 0.0, '_SL': 0.0, '_TP': 10, '_comment': 'good luck', '_lots': 1, '_magic': 123456, '_ticket': 0}, the _msg, TRADE;OPEN;1;USDJPY;0.0;0.0;10;good luck;1;123456;0, is sent to MT4 server. Yes, the server received the messege, and placed the order, however, immediately it closed the order.
2019.07.04 00:05:00.544 DWX_ZeroMQ_Server_v2.0.1_RC8 USDJPY,M1: open #179916973 sell 1.00 USDJPY at 107.785 ok
2019.07.04 00:05:00.746 DWX_ZeroMQ_Server_v2.0.1_RC8 USDJPY,M1: close #179916973 sell 1.00 USDJPY at 107.785 at price 107.798
Then I tried when the _TP is 0, the order can be placed and kept there.
Could you please give me some help?
Thanks.
Xiangyi
Hi, I have a lot of custom indicators that i would like to get the data from. Can you point me in the right direction?
Hello,
I want to thank you for your fantastic work. I've newly downloaded and installed ZMQ and all it's dependencies and done all the steps you have explained in your videos (regarding libraries, include folder and the settings in MT4). I have no problem with adding the expert to the MT4 charts and everything seems to work perfectly. When I open the Python file (DWX_ZeroMQ_Connector....py) after initializing the code I try to subscribe to the pair EURUSD as an example. Whenever I try to call the subscribed data using _zmq._Market_Data_DB.keys() (as you mentioned in your videos) I don't receive any real time data regarding the subsribed pair and I receive only the following response: dict_keys([]).
Generally it seems that I don't have any connection stablished between Python and the MT4 but I don't know, what can be the possible problem. Can you please help me?
regards,
The event listener 'OnTimer()' is not implemented in strategy tester.
Therefore triggering instead via 'OnTick()' does the trick within strategy tester.
I've got this working with the older version of the server script and a R-Client.
The newer one freezes the strategy tester, if triggered via 'OnTick()'. Any ideas here?
hi
i want implement machine learning/deep learning method in meta trader and find multiple approach
1- ENCOG library connect to mt with simple dll
2- ALGLIB library connect to mt with simple dll
3- mt4Rb7.dll can connect directly to R
4- matlab using read/write on single file
5- zeromq using socket to connect python / R
what is your opinion and what is best approach? and why ?
Hi, here is an image of the folder, how do I follow the steps in this link https://github.com/darwinex/DarwinexLabs/tree/master/tools/dwx_zeromq_connector?
Complete.
This ind works with suffix ? I am getting this under expert tab
2022.10.02 20:08:47.470 DLabs_CurrencyIndex EURJPYi,H1: Price unavailable @ time: 2022.04.08 01:00:00symbol: EURCAD
same for all pairs
Hi all
Thank you in advance for your support.
I have been operating with python code requesting y zmq market data and open positions. I can obtain open positions but when i have opened 18 or more trades, the method DWX_MTX_GET_ALL_OPEN_TRADES() gives me None as output instead of the open trades.
Have anybody had the same problem anytime. Could it be related with the waiting time of response?
Thank you in advance!
Just a heads up, I did a fresh install of MT4 and DLL imports were preset to off.
To fix, Tools > Options > Expert Advisors > Allow DDL Imports.
I also checked Allow Automated Trading.
Thank you for all of the open source code.
I Think I Installed everything as it should be and I get the Error:
NameError: name '_zmq' is not defined
When I run code like:
_zmq.DWX_MTX_GET_ALL_OPEN_TRADES()
In the Spyder Kernel.
How can I fix that?
Hi, I'm trying to use the HelloWorldServer.mq4 example from dingmaotu's GitHub with your sample Python code to test whether information is sent through the push pull socket. I think I've set up the various functions and libraries for MQL4 ZeroMQ properly. However, I get a TypeError because of a unicode string and get told to use "send_string" instead of "send". However, this doesn't send and receive "Hello World" either:
import zmq
eurusd_buy_order = "TRADE|OPEN|0|EURUSD|0|50|50|Python-to-MT4"
eurusd_sell_order = "TRADE|OPEN|1|EURUSD|0|50|50|Python-to-MT4"
eurusd_closebuy_order = "TRADE|CLOSE|0|EURUSD|0|50|50|Python-to-MT4"
get_rates = "RATES|GBPUSD"
def zeromq_mt4_ea_client():
# Create ZMQ Context
context = zmq.Context()
# Create REQ Socket
reqSocket = context.socket(zmq.REQ)
reqSocket.connect("tcp://localhost:5555")
# Create PULL Socket
pullSocket = context.socket(zmq.PULL)
pullSocket.connect("tcp://localhost:5556")
# Send RATES command to ZeroMQ MT4 EA
#remote_send(reqSocket, get_rates)
x= "Hello"
remote_send(reqSocket, x)
# Send BUY EURUSD command to ZeroMQ MT4 EA
# remote_send(reqSocket, eurusd_buy_order)
# Send CLOSE EURUSD command to ZeroMQ MT4 EA. You'll need to append the
# trade's ORDER ID to the end, as below for example:
# remote_send(reqSocket, eurusd_closebuy_order + "|" + "12345678")
# PULL from pullSocket
remote_pull(pullSocket)
def remote_send(socket, data):
try:
socket.send_string(data)
msg = socket.recv_string(flags=0,encoding='utf-8')
print(msg)
except zmq.Again as e:
print("Waiting for PUSH from MetaTrader 4..")
def remote_pull(socket):
try:
msg = socket.recv_string(flags=zmq.NOBLOCK)
print(msg)
except zmq.Again as e:
print("Waiting for PUSH from MetaTrader 4..")
zeromq_mt4_ea_client()
When trying to compile the expert on MT4 MetaEditor it gives me some errors.
-Single quote needed ( Lines : 147, 390,506,518...)
-Unknown symbol ( Lines : 147, 390,506,518)
-Invalid prepocessor command ( Lines : 2121...)
Any idea what can be the issue?
Thanks
Would it be possible to send commands from python to two MT4 terminals connected simultaneously?
D:\python\Python38\python.exe D:/python/DarwinexLabs/tools/dwx_zeromq_connector/v2.0.1/EXAMPLES/TEMPLATE/STRATEGIES/coin_flip_traders_v1.0.py
Traceback (most recent call last):
File "D:/python/DarwinexLabs/tools/dwx_zeromq_connector/v2.0.1/EXAMPLES/TEMPLATE/STRATEGIES/coin_flip_traders_v1.0.py", line 42, in
os.chdir(_path)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'tools\dwx-zeromq-connector\v2.0.1\python'
Process finished with exit code 1
I have tested your script in command line but I received this error. I have installed all modules python 2.7, pandas, and Darwin tick. Please, could you help me?
python -m darwinex_ticks EURGBP EURGBP USDJPY -u username -w passsword -n tickdata.darwinex.com -s "2018-10-08 10" -e "2018-10-08 12" -g
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/usr/local/lib/python2.7/dist-packages/darwinex_ticks/__main__.py", line 7, in <module>
except ModuleNotFoundError:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.