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
I'll support the topic starter, I've borrowed mql for many times as 4 and 5, and i'll say that i personally have little desire to learn the language that i can use only here in trading ...
Well, that's either for nothing or because you don't understand the problem. Are you really going to write the indicator algorithms all over again? It is like getting from Volgograd to Moscow via Vladivostok. One more thing, all indicators take into account the history. That is, if you take the data (bars) for a month, calculate the indicator according to your algorithm and compare it to Terminal, your calculations will be different.
I don't understand the phrase either:
Based on what I wrote, it turns out that there is a large layer of Python knowledge :) You open an editor and you already know python - it's so easy, and open mql and you don't know a thing.
At the same time, to call mql, whichis completely platform-oriented, an "obsolete" tool ... python was created in 1991 and this is much earlier
What I saw in this thread, written in python, is very easy to implement in mql
---
Well, it's interesting as a general idea, but not more.
Moreover he doesn't take advantages of Python and it's not "Python-style". It's like hammering nails with a screwdriver, the hammer is old-fashioned.
I suspect that the only crockery in your house is a spoon - you can make a soup or a cake and it's safer to use
)))
If you like it, use Python, but not as the topicstarter - don't create your own custom data types - bars and so on, don't write your own calculation ... and use existing solutions, otherwise there's no point in using this language, you may as well write your own neural network packages ;)
Yes) By the way, there's no library on Python for those trader's functions, or if you can write the full statistical analysis of a series in a couple of lines, you don't need MA)...
Yeah) By the way, there's no Python library for all sorts of near-trading functions, or if you can write a complete statistical analysis of a series in a couple of lines, then the MA is no longer needed)...
The Best 101 Python algorithmic-trading Libraries | PythonRepo
Couldn't get back to the forum yesterday. I will continue. I started a new demo account, and on it are the names of instruments without '_i' at the end, so I corrected the code in this part.
I will continue the gradual and slow movement, a kind of micro-tutorial, for those who may come in handy.
Let's introduce a variable n (small) - let it be, so to speak, the length of the window. That is, in files with prices, N readings, for example, 1000, and n, let's set, for example, 10, or 100, or 288 (a day, if the timeframe is M5).
The variable d for me means the shift of this window in time, into the past. Let's set d = 0.
For example, we will display 10 readings of closing prices and SMA of the order of 101 (delayed by 50 intervals between readings):
Result of work:
Let's learn how to interrogate the terminal about the current trades in the market, so to speak, for the instruments.
I will introduce the function
Let it take the list of open positions of the symbol and return the tuple(the number of deals to sell, the number of deals to buy).
In the main function add this fragment before the function terminal_done()
The result (n is reduced to 5 for the sake of the output):
I propose to start actual opening of trades. For example: if the price is higher than the SMA by some: open a sell trade, if it is lower than the SMA by some: open a buy trade.
I suggest a couple more functions: to control open trades in terms of SL and TP, close them if they are absent, and a function that returns the current result (profit or loss) in pips.
We have to remember to somehow handle the situation when the order is already in the history and it is not in the active position, and not to re-send the order for opening in this case.
This situation happens from time to time and, for example, working through Trade.mqh doesn't solve this problem (at least, it didn't before - I gave up Trade.mqh a long time ago).
Sometimes it is the other way around - the order to close is already in the history and the position is still visible.
We have to remember to somehow handle the situation when the order is already in the history and it is not in the active position, and not to re-send the order for opening in this case.
This situation happens from time to time and, for example, working through Trade.mqh doesn't solve this problem (at least, it didn't before - I gave up Trade.mqh a long time ago).
Sometimes it is vice versa - the order to close is already in the history and the position is still visible.
I showed how to interrogate the terminal regarding the open positions. Nothing prevents us from writing the code in such a way that if the position already exists, we would not need to resend the request, if not - we will. Especially, that after sending a request, the object is returned, which has everything in its properties, we can see whether it is normal, or what kind of error is present, and based on this act. There is no problem here.
The Best 101 Python algorithmic-trading Libraries | PythonRepo
It's already 104) It's 105)
Full code of the TradeLogic.py file so far (yes, it's primitive, but I'm sure it might open the door to trading using Metatrader 5 and Python for some)
Work result:
Z.I.Y. The most primitive, elementary, pieces of code shown, in my opinion, already demonstrate quite clearly that it is not difficult to implement absolutely any logic, any calculations, comparisons, control of open trades by various criteria, closing them automatically under some conditions, keeping logs both on the command line and by writing to files, etc., etc. - anything without any restrictions whatsoever.
Z.U.2 Till now used class Sdelka, and in general it is convenient to pass the objects of this class into functions, write them to files as .json, etc., - but somehow got a little tired, I think those who want to understand, I can help here with something. If you want, you can screw in a graphical interface.
I strongly recommend trading with Python + metatrader5 library.
I have shown how to poll the terminal for open positions. There is nothing that prevents you from writing the code so that if there is already a position, then you don't need to re-send the request, if not - send it. Especially, that after sending a request, the object is returned, which has everything in its properties, we can see whether it opened normally or there is an error, and based on this act. There are no problems here.
Once again, the order has already been executed and passed into history. It is no longer in the active position. The position has already been opened, but it is not visible yet; the request does not show it.
Usually, this is a very short time interval and it is difficult to reach it, especially since it is not always the case.
However, this situation may last not even seconds but minutes at a morning opening with a gap and a great amount of orders.
To make it clearer: TRADE_TRANSACTION_ORDER_DELETE has come earlier than TRADE_TRANSACTION_HISTORY_ADD or TRADE_TRANSACTION_DEAL_ADD
And we may not see orders in active or history at some point, or we may not see any orders or trades.