I was following the 7 video tutorials on how to interface python with a MetaTrader Terminal 4 and got no problem running them on iPython kernel just as instructed in this video
By no problem I mean a trade was sent to the server with ease and client (my laptop) received proper response after each action is executed. When I call zmq._get_response_()
I can get access to server response.
The problem starts to arise when I want to compile the DWX_ZeroMQ_Connector
class within a program. So I start with a simple program just like this :
def main():
zmq = DWX_ZeroMQ_Connector()
my_trade = { '_action': 'OPEN',
'_type': 0,
'_symbol': 'USOIL',
'_price': 0.0,
'_SL': 0,
'_TP': 0,
'_comment': 'dwx-zeromq',
'_lots': 0.01,
'_magic': 123456,
'_ticket': 0
}
#
zmq._DWX_MTX_NEW_TRADE_(_order=my_trade)
#
reply = zmq._get_response_()
all_trade = zmq._DWX_MTX_GET_ALL_OPEN_TRADES_()
#
print( "reply" + str( reply ) )
print( "----------------------" )
print( "alltrade" + str( all_trade ) )
main()
The weird part is this script STILL SENDS ORDERS SUCCESSFULLY, BUT DID NOT PROMPT ANY RESPONSE BACK as the reply turned out to be null. Was struggling with this for a week.
Some additional information :
I found the problem of not receiving response only when using Anaconda prompt to execute the compiled file, but I received proper response on iPython kernel so I presumed it could not be my dependencies. Both was running on local host
the github page I was cloning is the latest v2.0.1 RC8 version
Here is a picture of Console when I tried to set
_monitor = True
in the initialization process ofDWX_ZeroMQ_Connector
object. Now it even failed to send trades to MetaTrader Terminal 4 ( a Terminal-side DWX-code service-server ) and of course still failed to get any response back.Here is the copy of both Terminal Log and Expert Log examples when I tried getting a response from MT4 Terminal (server). As it was weekend, I had to experiment with bitcoin trade.
TERMINAL LOG
0 16:33:17.600 MetaTrader build 1260 started (Exness Ltd.)
0 16:33:17.600 Windows 10 Pro x64, IE 11, UAC, 4 x Intel Core i7-5500U @ 2.40GHz, Memory: 4899 / 8103 Mb, Disk: 73 / 99 Gb, GMT+7
0 16:33:17.600 Data Folder: C:\Users\Admin\AppData\Roaming\MetaQuotes\Terminal\F5C18A2156882613427FB4ACF0892997
2 16:33:20.664 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 USOIL,H1: loaded successfully
2 16:33:20.767 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 GBPJPY,H1: loaded successfully
0 16:33:22.258 '36006969': login on Exness-Trial4 through DC00 (ping: 235.09 ms)
0 16:33:24.299 '36006969': login datacenter on Exness-Trial4 through DC00 (ping: 235.09 ms)
0 16:33:24.933 '36006969': previous successful authorization performed from 171.255.70.226
2 16:33:31.235 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 GBPJPY,H1: removed
2 16:33:31.247 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 GBPJPY,H1: loaded successfully
0 16:33:42.019 '36006969': order buy market 0.01 BTCUSD sl: 0.00 tp: 0.00
0 16:33:42.514 Trades: use hosting service to speed up the execution - 0.33 ms via 'MQL5 Amsterdam 01 (MQL5.community)' instead of 235.09 ms
0 16:33:42.514 '36006969': order was opened : #2991084 buy 0.01 BTCUSD at 7110.21 sl: 0.00 tp: 0.00
2 16:35:11.850 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 USOIL,H1: removed
2 16:35:11.866 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 GBPJPY,H1: removed
0 16:35:12.081 MetaTrader build 1260 stopped
EXPERT LOG :
0 16:33:20.269 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 EURUSDm,H1: loaded successfully
0 16:33:20.270 DWX_ZeroMQ_Server_v2.0.1_RC8 EURUSDm,H1 inputs: PROJECT_NAME=DWX_ZeroMQ_MT4_Server; ZEROMQ_PROTOCOL=tcp; HOSTNAME=*; PUSH_PORT=32768; PULL_PORT=32769; PUB_PORT=32770; MILLISECOND_TIMER=1; t0=--- Trading Parameters ---; MagicNumber=123456; MaximumOrders=1; MaximumLotSize=0.01; MaximumSlippage=3; DMA_MODE=true; t1=--- ZeroMQ Configuration ---; Publish_MarketData=false;
0 16:33:20.664 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 USOIL,H1: loaded successfully
0 16:33:20.664 DWX_ZeroMQ_Server_v2.0.1_RC8 USOIL,H1 inputs: PROJECT_NAME=DWX_ZeroMQ_MT4_Server; ZEROMQ_PROTOCOL=tcp; HOSTNAME=*; PUSH_PORT=32768; PULL_PORT=32769; PUB_PORT=32770; MILLISECOND_TIMER=1; t0=--- Trading Parameters ---; MagicNumber=123456; MaximumOrders=1; MaximumLotSize=0.01; MaximumSlippage=3; DMA_MODE=true; t1=--- ZeroMQ Configuration ---; Publish_MarketData=false;
00 16:33:20.767 Expert DWX_ZeroMQ_Server_v2.0.1_RC8 GBPJPY,H1: loaded successfully
0 16:33:20.767 DWX_ZeroMQ_Server_v2.0.1_RC8 GBPJPY,H1 inputs: PROJECT_NAME=DWX_ZeroMQ_MT4_Server; ZEROMQ_PROTOCOL=tcp; HOSTNAME=*; PUSH_PORT=32768; PULL_PORT=32769; PUB_PORT=32770; MILLISECOND_TIMER=1; t0=--- Trading Parameters ---; MagicNumber=123456; MaximumOrders=1; MaximumLotSize=0.01; MaximumSlippage=3; DMA_MODE=true; t1=--- ZeroMQ Configuration ---; Publish_MarketData=true;