
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
Tired of debugging the snapshots. Finally made it perfect. One advisor, nothing. Two - perfect. 20 - disaster: CPU is under 100%. HistorySelect lags for many milliseconds.
It seems that MT5 is not intended for operating many Expert Advisors at the same time.
Are you writing a stress test or a usual Expert Advisor?
Most likely exactly a multi-threaded stress test in a single base. So I will repeat:
Forum on trading, automated trading systems and trading strategy testing
MT5 and Speed in Action
Renat Fatkhullin, 2020.09.16 12:47
If I understand correctly, there is not an EA there, but a stress tester on each symbol. This changes the case completely. And it shows the hiding of initial conditions.
That is, on 8(4+HT) CPU 16 threads (+N worker terminal threads in parallel) non-stop and without delay break into one synchronized symbol database object. Read/Write locks are mixed up because there is constant tick writing.
Usually in such a profile, depending on steepness of the processor and its mastering of threads, each thread can spend from 60% to 80% of time waiting.
And this is regardless of the type of task.
If you are actually having a non-stop battle for one resource in 20 threads, there are several options:
Read the box carefully. If N threads hit a single sync object, the empty wait will be at 60-80%.
And the limit of multi-threaded efficiency will be somewhere around 8-12 threads. As the number of threads increases, the sampling rate will drop. On 2600k the efficiency limit is even lower.
Are you writing a stress test or an ordinary expert's work?
Ordinary
Rather, it is a multi-threaded stress test in a single base. So I'll repeat:
If in fact you are doing a non-stop battle for a single resource in 20 threads, there are several options:
Read the box carefully. If N threads hit a single sync object, the empty wait will be at 60-80%.
And the limit of multi-threaded efficiency will be somewhere around 8-12 threads. As the number of threads increases, the sampling rate will drop. On 2600k the efficiency limit is even lower.
Fully caching history. But even this requires calling HistorySelect(0, INT_MAX).
As an experiment, I cut all the calls to history necessary for the trading logic. The load on the CPU has decreased very much.
Generally speaking, if there are 20 robots, calling them all over the history means that you can cause a disaster with only one terminal. About several Terminals we can't even talk about.
And it feels like synchro object is not only history. SymbolInfoTick, CopyTicks and something else, it seems.
Anyway, I can't even get five Terminals running with a dozen robots on each.
Looking at the braking profiler is a bummer.
Ordinary
Fully caching the history. But even this requires calling HistorySelect(0, INT_MAX).
As an experiment, I cut off all history calls necessary for the trading logic. The load on the CPU has decreased very much.
Generally speaking, if there are 20 robots, calling them all over the history means that you can cause a disaster with only one terminal. About several Terminals we can't even talk about.
And it feels like synchro object is not only history. SymbolInfoTick, CopyTicks and something else, it seems.
Anyway, I can't even get five Terminals running with a dozen robots on each.
Looking at the braking profiler is a bummer.
No evidence, nor numerical data.
1) How many times per second does each EA make HistorySelect queries?
2) Exactly which functions are slowing down?
3) Logs?
4) What is the principle of the robots?
All in all, if there are 20 robots, then to address the story in them is to cause a disaster with just one Terminal. Multiple Terminals is out of the question.
Maybe on the contrary - each terminal will support its own synchro object, and there won't be a queue of 20 EAs to it?
Try to run 1 robot on 1 terminal, it will be interesting to see the result.
Maybe on the contrary - each terminal will support its own sync object and there won't be a queue of 20 EAs to it?
Try to run 1 robot on 1 terminal, it's interesting to see the result.
Unfortunately, the result of this experiment will not answer the question, what to do?
Unfortunately, the result of this experiment will not answer the question, what to do?
Reconsider the concept of the trading robot
Added
I have 3 terminals on real + 1 demo in which I work
Each terminal has 42 robots that use OnBoorEvent from 3 to 4 characters,
Plus every 0.5 sec timer triggers + each robot accesses Global Variables of the terminal,
and it uses 8.34 GB of 32 GB of RAM and 6.7% of CPU
And nothing slows down, except for the TM5 server at the beginning of trading sessions.
There is no evidence, nor is there any numerical data.
1) How many times per second does each expert make HistorySelect queries?
2) Which functions exactly are slowing down?
3) Logs?
4) What is the principle behind the robots?
It's very hard for me to answer these questions, because even I myself can't get a handle on what's slowing down. The profiler doesn't even run. Their measurements are cheating, because the lag is already coming from the CPU. Reducing access to environment functions via snapshots and caching, unfortunately, did not give the expected effect. I am waiting for a profiler, which will be able to compile the Expert Advisor.
While I was busy, I found such a mess in the Strategy Tester with the trade history.
The result is
I have hardly noticed this bug and have been trying to write a replay for over an hour. The code is moronic but it shows the problem. Whether there is something similar not in the Tester but in the Terminal, I don't know.
Search string: Oshibka 013.
ZS b2626 - fixed.
Reconsider the concept of the trading robot
Only one robot that trades all symbols?
Only one robot that trades all symbols?
Different robots, but all built roughly on the same pattern.
There are 42 jobs involved in one terminal at a time, and on three, 126 is about 400 symbols
Added
To repeat (me)
Each robot uses OnBoorEvent from 3 to 4 characters,
plus every 0.5 sec a timer is triggered + each robot accesses theGlobal Variables of the terminal,
8.34 GB of 32 GB of RAM and 6.7% of CPU usage
And nothing slows down, except for the TM5 server (or the Openreach hardware) at the start of trading sessions.
Different robots, but all built roughly according to the same scheme.
There are 42 jobs involved in one terminal at a time, and on three - 126 is about 400 characters
Added
To repeat (me).
Each robot uses OnBoorEvent from 3 to 4 characters,
plus every 0.5 sec a timer is triggered + each robot accesses theGlobal Variables of the terminal,
8.34 GB of 32 GB of RAM and 6.7% of CPU usage
And nothing is slowing down, except for the TM5 server (or Open's iron) at the start of trading sessions.
Here's the weird thing, it's the opposite for me.
My device has 4 terminals, I have reduced the number of Expert Advisors to about 200, I`ve cut all OnBooks, switched back to OnTick and updated my hardware but the problems are the same as with fxsaber.
But there are no lags in the morning in my Opener for a long time already. And what they used to be! Up to 75 seconds sometimes :)