You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
IMHO, trading via Python is a PR move by MQL5.
Who prevents you from calculating the indicator data? Or pass the data of custom indicators to python from mql?
Who prevents you from calculating indicator data? Or pass data of custom indicators to python from mql
Can you give an example, at least in pseudocode. We create a script in python. I want to receive the Bollinger's data (Ishimoku, etc.) for a certain time period. How do I do it?
Trading with a python is good...
...
Python stores quotes and indicators on SQLite. MQL-python communication via socket, files or database (socket is better).
You are right of course. But I want to help people who are not familiar with databases, sockets of some kind to enter algorithmic trading...
So let's make it simple - through files. Clearly, and enough to work with.
I propose to make three files:
Classes.py - to put all sorts of classes in there, not necessarily all of them, just the ones that need it, so that there is no unnecessary cluttering code in the main file;
Functions.py - for storing there all sorts of functions, not necessarily all of them, just the ones that need not to be cluttered code in the main file;
TradeLogic.py - main file.
I will put classes of timing, bar, and trade in the Classes.py file (a blank trade class):
No explanations yet, explanations will be provided as we go along.
Can you give me an example, at least in pseudocode? Create a script in python. I want to get Bolinger (Ishimoku, etc.) data for a given time. How do I do it?
I.e., give an example of how to save data of any indicators in csv-file or SQLite and then read it in python? It will not be funny?
In the file TradeLogic.py I suggest writing this to start with:
Here are some imports of what will be needed later, and the program itself starts with line N=1000. The address "work_catalog" is the directory where I plan to save files with prices and, if necessary, others. The address is so strange, because I use Metatrader in virtual machine and for this demonstration Python - also there, instruments - the list of instruments on which we plan to trade.
i.e. give an example of saving any indicator data to a csv file or SQLite and then reading it into python? It will not be funny?
No, it won't be funny. There are a lot of people who can quickly start algorithmic trading with Python, but are currently not familiar with Python at all, and have a feeling that they don't need MQL, are not ready to spend time learning a tool that has extremely narrow application. Don't speak about C-like syntax either, there are too many people unfamiliar with C/C++ at all.
The purpose of this branch is to give specific instructions to people who do not know where they should start with algorithmic trading. A starter kick. Without any unnecessary complications.
The metatrader5 library will be used to manage the Metatrader5 terminal.
Library here:https://pypi.org/project/MetaTrader5
Documentation here: https: //www.mql5.com/ru/docs/integration/python_metatrader5
Using the functions described in the library, implement the functions for initiating a connection to the terminal and for terminating a connection to the terminal. We plan to do it in infinite loop every 5 minutes.
Also write the dt_stamp_from_M5_view function that will create a count of date-time(object of class date_time) from the '202112101635' type string (I call it M5_view).
Let's put this code into TradeLogic.py file:
This code is already functional. I.e., it starts up, determines the nearest equal multiple of 5 minutes, + 10 seconds (to ensure that server bars will close, we want to save quotes), sleeps to this moment, wakes up, connects to the terminal, trades (in the sense that it does nothing), ends connection to the terminal, sleeps for 5 minutes - and the cycle repeats.
Program operation: