我有一个简单的)
脚本,我想从MQL4 EA运行。
我该如何实现?
我尝试过使用 test.py
,但这在我的情况下不起作用,因为我在linux机器上运行MetaTrader4终端,因此无法调用基于ShellExecute()
的窗口(甚至使用ShellExecute()
)。
答案 0 :(得分:0)
wine
- 承诺具有完整的DLL抽象 wine
项目,如果配置正确,应该提供完整的DLL抽象,以便合法的ShellExecute()
应该提供一种方法来启动一个葡萄酒笼罩的MetaTrader4终端,启动这样的预期过程
鉴于此选项在ZeroMQ v2.11之后可行,python始终准备好与MQL4进行通信并启动/停止任何服务供应 - {MQL4|*}
- demand。这将是我的首选方式,因为工作流程并不孤立于“即发即忘”。导弹控制。
使用这种架构多年,用于AI / ML预测器预测引擎,远程键盘,异地集中智能日志记录,流程健康/性能 - 遥测服务集成(不仅与MQL4代码执行单元)和剩余选择这种先进的分布式架构方式多年来一直很开心。
Nota Bene:值得注意的是,在MQL4 Build 850/900 MetaTrader4终端代码执行引擎版本的某处为DLL-wrapper /创建了几十个headbang问题原始的ZeroMQ v2.11包装器,但是一些适度的努力使{em>新 - MQL4.56789
更改为string
,其停止为 string
< / strong>(令人惊讶的是重新打扮 struct
),但在大多数高性能处理交互中都是有点紧张的,所以不应该出现心碎。子>
def main():
# setup ZeroMQ infrastructure and map all resources
import zmq
...
pass; mainloopSTAY = True
# mainloop(): -----------------------------
while mainloopSTAY:
try:
# ----------------------- event-handling:
pass;
except:
# ------------------------- EXC-handling: { continue }
pass;
finally:
# dismantle ZeroMQ infrastructure and release all resources
pass; print( "INF: main().finally: EXIT" )
# { break | if mainloopSTAY }
#----------------------------------------------
pass; print( "INF: main().pre-return SECTION" )
if __name__ == '__main__':
main() # EXECUTED only if this module-file was called to run from a command-line ( Ref. SECTION: import for def: )
#include <mql4zmq_for_Terminal_4.00_Build.840.mqh> // STILL BUG/ERROR on zmq_poll() while missing zmq_poll_struct_t
string aTemp = ">>> "; // globally visible ...
int aZmqCONTEXT, // globally visible ...
aZmqSOCKET; // globally visible ... so as to be able to auto-deinit in { EA -s | #Indicators } .deinit() on panic termination(s)
//+------------------------------------------------------------------+
//| msMOD_deinit( int aZmqSOCKET = EMPTY ) |
//+------------------------------------------------------------------+
void msMOD_deinit( const int aZmqSOCKET = EMPTY ) {
if ( aZmqSOCKET != EMPTY ) {
zmq_setsockopt( aZmqSOCKET, ZMQ_LINGER, 0 );
zmq_close( aZmqSOCKET );
}
zmq_term( aZmqCONTEXT );
return;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit( const int anAutoDeinitREASON ){ // auto-generated ONLY for { EA-s , #Indicator-s }
msMOD_deinit( aZmqSOCKET );
}
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{ aZmqCONTEXT = zmq_init(1); // .init into globally visible int
if ( aZmqCONTEXT < 0 ){
msMOD_deinit(); // GRACEFUL CLEANUP
return; // DEBUG: RET()
}
int aZmqPAIR = zmq_socket( aZmqCONTEXT, ZMQ_PAIR ); // .sock PAIR
if ( aZmqPAIR < 0 ){
msMOD_deinit( aZmqPAIR ); // GRACEFUL CLEANUP
return; // DEBUG: RET()
}
int aZmqBindPAIR = zmq_bind( aZmqPAIR,
"tcp://A.B.C.D:PORT" // i5-eth0-IP:#####
);
if ( aZmqBindPAIR < 0 ){
msMOD_deinit( aZmqPAIR ); // GRACEFUL CLEANUP
return; // DEBUG: RET()
}
...
int RC = mql4zmq_msg_init_data( aSendMsgOBJ, aSendMsgBuffUCHAR, aSendMsgBUFF_SIZE * 4 );
zmq_send( aZmqPAIR, aSendMsgOBJ );
...
}