We need to get as few cycles per tick as possible.
We need to have one constant array with data of market orders and positions and one array with data of deleted/closed orders and positions
If we have the array locally in a function, calling it repeatedly requires filling it again. I suggest that it is filled only once at a new tick - so the array is global, otherwise we would lose it when exiting the function.
In order to find something in it (in the array), we need a filled array and functions that will return the found data. Within functions, we can declare auxiliary arrays for necessary calculations.
For this reason, it would be better to have global arrays - for closed and open orders and positions. Once on a new tick, we pass the necessary amount of orders/positions once, filling the two arrays with them. And then we get all the necessary data from them on the same tick. Note that not only the last closed/open order/position and all its data are calculated, but also all parent and child ticks of all positions are searched in case of partial closing. Accordingly, at any time I can see which ticket originated from one or another position, if it has been closed partially more than once - all this already works in a class that runs in a timer. I have many other data I need with a small total number of cycles. The necessary depth of history for arrays is set for the tester.
And so on and so forth ...
Sorry. One more addition (not to counterbalance, but as an addition), I'd like to add that local arrays withstatic are not lost. That is, if conditions allow you to do without declaring them globally.
I'm now slowly rewriting it for 5. I mean that price may change very quickly and the level may be less than the stop-loss value, which will lead to an error. I mean that the price may change very quickly and the level will be less than the allowable stop level, which will lead to an error.
I understand that this"SymbolInfoTick" thing is needed to get the current price?
So, to get the actual Ask and Bid in mql4, the refresh should have been called anyway. And it turns out that the load is unlikely to change compared to calling SymbolInfoTick().
But here's another addition: I write SymbolInfoTick() in the following loop to get accurate prices
do while(!SymbolInfoTick(_Symbol, mqlTick));
If we get normal prices from the first time, this loop will not increase the execution time. And if there's some failure, it's better to repeat than to get the same price instead of the current one.
So, to get actual Ask and Bid in mql4, you have to call refresh anyway. And it turns out that the load is unlikely to change compared to calling SymbolInfoTick().
But here's another addition: for error-free getting of actual prices, I put SymbolInfoTick() into this loop
do while(!SymbolInfoTick(_Symbol, mqlTick));
If we get normal prices from the first time, this loop will not increase the execution time. And if there's some failure, it's better to repeat than to get the same price instead of the current one.
I see, where should we put it, inside or before the loop?
Vitaly Muzichenko: I see, but where should I put it, inside the cycle, or before?
Well, it's a separate cycle until we get the current prices. We have already discussed where to put it. If there is an ambush with not actual prices, we should set it in the loop of order evaluation.
So, to get actual Ask and Bid in mql4, you have to call refresh anyway. And it turns out that the load is unlikely to change compared to calling SymbolInfoTick().
But here's another addition: for error-free getting of actual prices, I put SymbolInfoTick() into this loop
do while(!SymbolInfoTick(_Symbol, mqlTick));
If we get normal prices from the first time, this loop will not increase the execution time. And if there's some failure, it's better to repeat than to get the same price instead of the current one.
And if you don't get them at all? How do you slow down the loop?
Artyom Trishkin: And if it doesn't receive it at all? How do you slow down the cycle?
Yes, logically it could be, for example, the terminal has lost connection - there are plenty of reasons for that, I have had it lose connection 50 times a day.
What's the best way to get up-to-date prices, while being less resource-intensive, mind you - for the grid trawl.
Yes, logically it could be, for example, the terminal has lost connection - there are plenty of reasons for that, I have had it lose connection 50 times a day.
What's the best way to get up-to-date prices, while being less resource-intensive, remember - for the grid trawl.
problem solved by comparing prices
In this context, my point is this:
For this reason, it would be better to have global arrays - for closed and open orders and positions. Once on a new tick, we pass the necessary amount of orders/positions once, filling the two arrays with them. And then we get all the necessary data from them on the same tick. Note that not only the last closed/open order/position and all its data are calculated, but also all parent and child ticks of all positions are searched in case of partial closing. Accordingly, at any time I can see which ticket originated from one or another position, if it has been closed partially more than once - all this already works in a class that runs in a timer. I have many other data I need with a small total number of cycles. The necessary depth of history for arrays is set for the tester.
And so on and so forth ...
Sorry. One more addition (not to counterbalance, but as an addition), I'd like to add that local arrays withstatic are not lost. That is, if conditions allow you to do without declaring them globally.
I'm now slowly rewriting it for 5. I mean that price may change very quickly and the level may be less than the stop-loss value, which will lead to an error. I mean that the price may change very quickly and the level will be less than the allowable stop level, which will lead to an error.
I understand that this"SymbolInfoTick" thing is needed to get the current price?
So, to get the actual Ask and Bid in mql4, the refresh should have been called anyway. And it turns out that the load is unlikely to change compared to calling SymbolInfoTick().
But here's another addition: I write SymbolInfoTick() in the following loop to get accurate prices
while(!SymbolInfoTick(_Symbol, mqlTick));
If we get normal prices from the first time, this loop will not increase the execution time. And if there's some failure, it's better to repeat than to get the same price instead of the current one.
So, to get actual Ask and Bid in mql4, you have to call refresh anyway. And it turns out that the load is unlikely to change compared to calling SymbolInfoTick().
But here's another addition: for error-free getting of actual prices, I put SymbolInfoTick() into this loop
while(!SymbolInfoTick(_Symbol, mqlTick));
If we get normal prices from the first time, this loop will not increase the execution time. And if there's some failure, it's better to repeat than to get the same price instead of the current one.
I see, but where should I put it, inside the cycle, or before?
So, to get actual Ask and Bid in mql4, you have to call refresh anyway. And it turns out that the load is unlikely to change compared to calling SymbolInfoTick().
But here's another addition: for error-free getting of actual prices, I put SymbolInfoTick() into this loop
while(!SymbolInfoTick(_Symbol, mqlTick));
If we get normal prices from the first time, this loop will not increase the execution time. And if there's some failure, it's better to repeat than to get the same price instead of the current one.
And if it doesn't receive it at all? How do you slow down the cycle?
Yes, logically it could be, for example, the terminal has lost connection - there are plenty of reasons for that, I have had it lose connection 50 times a day.
What's the best way to get up-to-date prices, while being less resource-intensive, mind you - for the grid trawl.
Yes, logically it could be, for example, the terminal has lost connection - there are plenty of reasons for that, I have had it lose connection 50 times a day.
What's the best way to get up-to-date prices, while being less resource-intensive, remember - for the grid trawl.
check back 10 pages, there's a pretty good schematic there.