Questions from Beginners MQL4 MT4 MetaTrader 4 - page 250

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
If it's simple, to check quickly, it's something like this:
Orders usually follow one another in time, but this is not guaranteed. Therefore, the chronology should be checked. But for experiments this will do.
If it's simple, to check quickly, it's something like this:
Orders usually follow one another in time, but this is not guaranteed. Therefore, the chronology should be checked. But this will do for experiments.
I agree, the timing is not guaranteed. That is why I want to go through all of the closed orders by the ticket. I know the order ticket and am trying to count from it, but something has gone wrong) What would be the right way?
If it's simple, to check quickly, it's something like this:
Orders usually follow one another in time, but this is not guaranteed. Therefore, the chronology should be checked. But this will do for experiments.
If we look through the history, it would be better to look through the orders from smaller to larger ones that would close at the moment of recalculation as market orders are considered from larger to smaller ones so that we could correctly consider those opened and closed on the same tick. I think so)
If it is simple to quickly check, then it is something like this:
As a rule of thumb, orders follow each other in time, but this is not guaranteed. Therefore, in a good way, the chronology should be checked. But it will do for experiments.
Doesn't Alexey's code get it right too?
In the history it is better to go from less to more orders to take into account those that will close at the time of recalculation, it is the market orders we count from more to less to correctly account for open and closed on the same tick. I think so)
Does Alexey's code also calculate incorrectly?
I have not tried it. I will try it now. I will let you know.
If it's simple, to check quickly, it's something like this:
Orders usually follow one another in time, but this is not guaranteed. Therefore, the chronology should be checked. But it will do for experiments.
I checked it and got a lot of errors during compilation, I fixed them all, except for :
if(profit>max)
This line, I don't quite understand it. Can you explain?
The idea is to change the ticket after you reach a certain profit
The max is the limit of the profit after which the ticket changes. The value is set by you.
The max is the limit of the profit after which the ticket changes. Its value is set by you.
The problem is different, if I understand it correctly. There are 1, 2 and 3 orders. I do not know how the open prices are formed. Order 3 is closed, the total profit is equal to the profit of order 3. I.e. we need to calculate the ticket for the order opened before order 3 . Then order 2 is closed. We should find the ticket of the order opened before order 2. The total profit is equal to the profit of orders 2 and 3.
I do not understand why, but it seems to be the logic.)
Valery, I didn't fully understand the logic on those two sentences.
Forum on Trading, Automated Trading Systems and Strategy Tests
FAQ from Beginners MQL4 MT4 MetaTrader 4
makssub, 2021.09.01 16:38
I should use the first function to find the required order ticket and the second function should calculate the profit of all closed orders following that ticket. I am not interested in profit of the ones before that. But the second one does not calculate it correctly. When an order is opened these 2 functions are called and therefore it should be equal to 0, but it is not.
PS took your advice, gave up arrays)
12th box above)
I have thought of everything and made it my own based on your tips)
The task was to cover a losing order with other orders at profit.
We have implemented it. We memorized the ticket of the order opened after the losing one; this was our report point. After this point, we start calculating the profit of the loss-making order and the profit of the closed orders after it. Let me remind you that the first order is open and we close it when it reaches a profit.
if ( (CalculateProfitHistory() + FirstProfit() >= Profit)
{
CloseFirst();
Print ("Close the first losing order");
}