opentrading / otmql4py Goto Github PK
View Code? Open in Web Editor NEWOpen Trading Metatrader 4 Python Integration
License: GNU Lesser General Public License v3.0
Open Trading Metatrader 4 Python Integration
License: GNU Lesser General Public License v3.0
In OTPyTestNullEA.mq4
int OnInit(){
...
...
iRetval = iPyEvalInt("os.getpid()"); //cause mt4 hang
}
Log file:
2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)]
vPyInit - Opened d:\MT4\MQL4\Python\OTMql427../../Logs/_test_PyTestNullEA.txt d:\MT4\MQL4\Python\OTMql427../../Logs/_test_PyTestNullEA.txt
vPyInit - Thread MainThread number 1556
Exception KeyError: KeyError(3528,) in <module 'threading' from 'C:\Python27\Lib\threading.pyc'> ignored
Work around by not a good solution:
//iRetval = iPyEvalInt("os.getpid()");
//replace as
iRetval = uPySafeEval("os.getpid()");
Essential information for reporting Issues:
I have python27 which is installed by Anaconda. Is there anyways that we can connect this API to Anaconda Python?
I added my Anaconda folder to my environment variable, but it didn't help (python27.dll is in the main folder of Anaconda. However, the other dlls are in different folders)
There are many libraries and packages already installed in Anaconda and would be great if we can access to them.
For example in OTMql4Py/MQL4/Libraries/OTMql4/OTPyChart.mq4, you included "#include <OTMql4/OTZmqProcessCmd.mqh>", while there is no such file called OTZmqProcessCmd.mqh.
Essential information for reporting Issues:
Hello,
I tried using this library. But when I try executing the script OTMql4PyTest.mq4 or running the EA OTPyTestNullEA.mq4, I get the error: python27.dll could not be loaded.
It's coming from the py27.dll but I can pinpoint further what's causing it. I can make sure that I have the python27.dll on my system32 folder but seems I cannot find these dlls pythoncom27.dll, pythoncomloader27.dll, pywintypes.dll.
Thanks!
I think it would be nice to have a python style api just like TradePlatform.NET has a C# wrapper over trading functions:
This python api could be used both in embedded python and have an implementation that runs externally that uses zeromq to send the commands.
I know about do_order perhaps this api could just call do_order?:
https://github.com/OpenTrading/OpenTrader/blob/6b9625ec2b672ba73f0b846913a3d52ae1f1b659/OpenTrader/OTCmd2.py#L789
Hi there,
installing MT4 (newer versions?) into the default directory creates the terminal data folder (MQL4, logs, etc.) inside the users AppData folder. While TerminalPath() returns the directory of your MetaTrader 4 installation, what you actually need to make OTMql4Py work is the data folder path. Therefore i'd suggest to exchange TerminalPath() with TerminalInfoString(TERMINAL_DATA_PATH) to get the expected path.
cheers
Essential information for reporting Issues:
I was looking to call Python from MT4, MT4 will pass a few arrays of doubles to Python which will use the arrays to calculate and return a double back to MT4. MT4 will then draw an indicator using the return value.
Can this be done? Is there an example to start with? I installed and tried with a simple script in MT4, it hanged MT4 with access violation:
#include <OTMql4/OTPy27.mqh>
int OnStart(){
uchar expr[];
StringToCharArray("a=""a string""",expr);
PyInitialize();
int s=PyEvaluate(expr);
StringToCharArray("a",expr);
s=PyEvaluate(expr);
s=PyGetString(s);
printf("%s",s);
return(0);
}
Essential information for reporting Issues:
Any plans to support python 3.x? was wondering if there was any reason to only support the older version of python. Can you have more than 1 version of python installed? If so, how can I best do this to avoid conflicts?
Downloaded the Zip from master and copied folder MQL4 following instalation instrutions, tried to execute the test script MQL4/Scripts/OTMql4/OTMql4PyTest.mq4 with error: Cannot call 'OTMql4/OTLibPy27.ex4::iPyInit', 'OTMql4/OTLibPy27.ex4' is not loaded. Trying to compile OTLibPy27.mq4 raises the vLogInit() not defined
My testing system is summarized as below
I installed the whole Opentrader which might need OTMMql4Py. I tried the Mql4ZMQtestEA, it works well. When I tried to load Python related EA or scripts, MT4 crashed immediately. I think it is a incompatible version of python related issues. Any idea how to identity or solve this problem?
Hi OpenTrading,
Did you ever try "named memory pipes"
A DLL-free solution to communicate between MetaTrader 5 terminals using Named Pipes July, 2010
http://www.mql5.com/en/articles/115
Communicating With MetaTrader 5 Using Named Pipes Without Using DLLs
http://www.mql5.com/en/articles/503
Kind regards
Line 12 of the file OTMql4PyTest.mq4 #include <OTMql4/OTLibLog.mqh>
must be changed to #include <OTMql4/OTLibPyLog.mqh>
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.