
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
There may be a faster option. But one step to the left in the condition of what needs to be counted, and the logic may have to change considerably. Not easy, in general.
It's not caching, it's indexing. Here is caching (part of code):
The code was written hastily and there is a lot to refine, given the frequent ArrayResize, but it exactly updates the cache, sorted by Closed. If you want to search later, use your own index. But you only have to update a small part each time.
I don't remember why"12*3600" is there, I don't think all deals were issued to me.
It's not caching, it's an index.
Please read carefully.
Forum on trading, automated trading systems and trading strategy testing
MT5 and Speed in Action
fxsaber, 2020.08.28 21:10
Pure MQL5 is 100x slower than partial (only HistorySelectByPosition) caching.
Here is caching (part of code):
The code was written hastily and has some things to improve considering frequent ArrayResize, but it updates cache sorted by Closed. You want to search later, use your own index. But you only have to update a small part each time.
This is just an example of a head-on history saving without the real-world gimmicks. Even in MT4Orders partial caching is done with a five second margin...
I don't remember why"12*3600" is there, I don't think all trades were issued to me.
Always set INT_MAX.
Architecturally, doing full caching takes a lot of thinking. There are a lot of pitfalls.
There's really nothing complicated there. You can do a sampling with hours to spare, for example, for all orders that might appear in history retroactively (which is very strange, by the way).
This is just an example of head-on history saving without any real-time gimmicks. Even in MT4Orders partial caching is done with a five second margin...
Always set INT_MAX.
I don't understand the point of the shift. As if there is a current timestamp, I want to get relative to it and it's strange that you have to specify a time that doesn't exist. I kind of want a logical explanation.
My cache, by the way, works on real accounts with 10k+ trades.
And the main brakes in the code so far are the network functions.
In the latest beta 2588, the HistorySelect feature is very well cached and almost always (except for the first time) is free.
We are likely to make a number of other improvements by the release.
As I explained earlier, in MT5 there is no extra cost in automatically creating market snapshots for each EA before each event as it was done in MT4. This reduces delays and allows the robots to run faster. Each developer asks exactly what he needs.
Therefore, you should clearly understand that the approach of "calling HistorySelect on the whole history, and then immediately make another selection of HistorySelectByPosition" will kill the previously created caches of history. This is a shot in the foot.
After the release we will start a big work on adding new more efficient MQL5 functions and open native order/trade data structures, so we can simplify and speed up algotrading.
In the latest 2588 beta, the HistorySelect function is very well cached and almost always (except the first time) is free.
Result.
On every tick there is a problem.
ZY installed Win10, LatencyMon shows that everything is fine.
After the release we will start a lot of work to add new more efficient MQL5 functions and open up native order/trade data structures so that algorithmic trading can be simplified and accelerated.
MqlDeal, MqlOrder and MqlPosition would be great. It might even become simpler.
At the moment, I see that in 99% of cases we should only use HistorySelect(0, INT_MAX). Try not to use the other options.
If I have hundreds of thousands of orders in my history, will it also be faster than taking the last minute history?
So do I have to go through all of this history? It does not make sense.
If I have hundreds of thousands of orders in my history, is it also faster than taking the last minute history?
Left only 0-INT_MAX variant in combat robots. Stopped noticing the lags.