With what to replace OnTradeTransaction() in mql4? - page 6

 
Vitaly Muzichenko:

No, but maybe we're talking about different things.

This will always work.

Still made me open the terminal and check... Here are three runs of the same script and three results.

There's only one line in the script.

  Print("OrdersHistoryTotal ", OrdersHistoryTotal());
2020.01.27 18:28:51.063 Script 00 EURGBP,H4: removed
2020.01.27 18:28:51.063 00 EURGBP,H4: uninit reason 0
2020.01.27 18:28:51.063 00 EURGBP,H4: OrdersHistoryTotal 48
2020.01.27 18:28:51.063 00 EURGBP,H4: initialized
2020.01.27 18:28:51.043 Script Test\00 EURGBP,H4: loaded successfully
2020.01.27 18:28:38.203 Script 00 EURGBP,H4: removed
2020.01.27 18:28:38.193 00 EURGBP,H4: uninit reason 0
2020.01.27 18:28:38.193 00 EURGBP,H4: OrdersHistoryTotal 47
2020.01.27 18:28:38.193 00 EURGBP,H4: initialized
2020.01.27 18:28:38.183 Script Test\00 EURGBP,H4: loaded successfully
2020.01.27 18:28:16.443 Script 00 EURGBP,H4: removed
2020.01.27 18:28:16.443 00 EURGBP,H4: uninit reason 0
2020.01.27 18:28:16.443 00 EURGBP,H4: OrdersHistoryTotal 4
2020.01.27 18:28:16.443 00 EURGBP,H4: initialized
2020.01.27 18:28:16.423 Script Test\00 EURGBP,H4: loaded successfully

I mean that if an EA is working and a user decided to change the range of history displaying with his naughty hands, the EA will go crazy during the second switch. Now it will be smaller, now it will be larger, now it will be different from the memorized one. And even if the line

  if(HT!=__TotalHist)

put > instead of !=, the situation will not change. If the EA is running when the setting is set to "Today" and switch to "All history"... what happens?

 
Aleksandr Volotko:

I wouldn't dream of touching OrderHistoryTotal(), why should I?

Just in case:))))

 
Alexey Viktorov:

Just in case:))))

:))) OrdersTotal() is good enough for me

Maybe to make two timers? one compares OrdersTotal() values even once in 100 ms, and the second for safety once in a minute (or less frequently) in a loop - no mouse can miss there, if one of two dozen trades closes/opens once in 100500 times a minute later - I certainly will not die, I suppose the deposit too.

 
Aleksandr Volotko:

:))) OrdersTotal() is enough for me

Maybe I should make two timers? One of them compares OrdersTotal() values even once in 100 ms, and the second one - once in a minute (or less frequently) goes through the loop - not a single mouse can get through there, if one of two dozen trades closes/opens one minute later, than 100500 times - I surely won't die, and I suppose so will my deposit.

And how many orders open at the same time is provided by the algorithm?

 
Alexey Viktorov:

Still made me open the terminal and check... Here are three runs of the same script and three results.

There is only one line in the script

What I mean is that if the EA works and a user decided to change the range of history displaying with his naughty hands, the EA will go crazy during the second switch. Now it will be smaller, now it will be larger, now it will be different from the memorized one. And even if the line

The situation will not change if we put > instead of !=. If the Expert Advisor is run at the moment when the setting is "Today" and switch to "All history"... what will happen?

In any case, it will not be equal, and the code will go further. But if we setif(HT >__TotalHist), then we will face problems.

 
Alexey Viktorov:

And how many open orders does the algorithm stipulate in total?

Two or three dozen at the most.

 
Vitaly Muzichenko:

In any case, it won't be equal and the code will move on. But if (HT >__TotalHist)then there is a problem

Vitaly, there will be problems in any case. Whatever way you look at it, if the EA is to react to changes in the amount of orders in the history, it will react regardless of how the amount of orders has changed. As a matter of fact, the amount of orders in the history can only increase, that is why I suggested that it would be less dangerous, but it does not solve the problem. Even if you have written it solely for yourself, you cannot rule out the possibility of manual switching. You never know what kind of text message will come to your mind)))

 
Aleksandr Volotko:

2-3 dozen at the most

For such a number, it would be easier to create an array of tickets or even an array of structures with order properties and check the change of type and close time on each tick. This will allow us to trace the activation of a pending order or closing of a position. And opening immediately after sending OrderSend(), add the size of the array and put everything you need in it.

 
That's the thing, you can shake orders 86400 times a day, but you didn't want to.
 
Aleksandr Volotko:
That's the thing, you can shake orders 86400 times a day, but you didn't want to.

In that case, it would be hard to live without Artem's library.

Reason: