If you want it to drop, you will have to make up for it in speed.
So it will take slightly longer.
For example when you run the mechanism in OnMillisecondTimer() function you can set the timing interval by EventSetMillisecondTimer();
Then you simply ++i on every timer cycle in stead of in that loop so you have to adjust the code a bit.
- Are you sure this CPU usage is due to MT5 ?
- It's not a good idea to execute such code in OnInit(), initialization should be fast.
- I tried your code, 328 symbols, it took 2 minutes 30. The CPU usage was from 24% when it starts to maximum 41% (I have Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz, and a lot of other applications running)
To me looks as if MQL5 is able to start several (300) independent threads for CopyRates. Have you looked at the single threads and their 'distribution' on the kernels??
If you want it to drop, you will have to make up for it in speed.
So it will take slightly longer.
For example when you run the mechanism in OnMillisecondTimer() function you can set the timing interval by EventSetMillisecondTimer();
Then you simply ++i on every timer cycle in stead of in that loop so you have to adjust the code a bit.
To me looks as if MQL5 is able to start several (300) independent threads for CopyRates. Have you looked at the single threads and their 'distribution' on the kernels??
- Are you sure this CPU usage is due to MT5 ?
- It's not a good idea to execute such code in OnInit(), initialization should be fast.
- I tried your code, 328 symbols, it took 2 minutes 30. The CPU usage was from 24% when it starts to maximum 41% (I have Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz, and a lot of other applications running)
Yes this is MT5 usage .
You are Right . I put in OnInit just for run and test
scale of usage Percent depend to CPU power.
But amount of usage not my problem.
Why after any run copyrates and CPU occupy then end copyrates , CPU not release ?
It is My problem : How i release CPU usage after any run copyRates ????
When i can release CPU after any copyRates , so i can solve this problem
Yes this is MT5 usage .
You are Right . I put in OnInit just for run and test
scale of usage Percent depend to CPU power.
But amount of usage not my problem.
Why after any run copyrates and CPU occupy then end copyrates , CPU not release ?
It is My problem : How i release CPU usage after any run copyRates ????
When i can release CPU after any copyRates , so i can solve this problem
You should talk to ServiceDesk.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi . i make this cod for get rates of all symbol in marketwatch
But when number of symbol in market watch is too much ( 300 symbol ) my CPU Be filled slowly & empty slowly
for example any copyRates use 2% of my CPU and i think after any CopyRates my CPU must be empty and then refill another 2%
But not like that . in process any 2% sum whit before 2% and full my CPU . And after finished loop my CPU not empty immediately and fast
I don't want use sleep() between any copyrates for solve my problem.
I want do fast and light. How i can do that ?
Than you for your guide .
(This Is My CPU In Process)
int TotallSymbol ,
BarNum ;
string Symboll ;
struct MqlRatesAll
{
MqlRates Rates[];
string Name;
};
MqlRatesAll SymList[];
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
TotallSymbol = SymbolsTotal( true );
ArrayResize( SymList , TotallSymbol );
for( int i=0 ; i<TotallSymbol ; i++ )
{
Symboll = SymbolName( i , true );
CopyRates( Symboll , PERIOD_D1 , 0 , 10 , SymList[i].Rates );
SymList[i].Name = Symboll;
}
//---
return(0);
}