How i can get all symbol rates of market watch Without full my CPU - page 2

 
Ehsan Tavakoli:

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

I don't understand you problem!

The slow increase and slowdown of the cpu usage is most probably caused bay the latency the download of the quotes for a symbol causes. That means that all your threads do not start their cpu-usage (copyRates) at the same time and do not end at the same time!!

So all what you see is normal - I guess -  in times of parallel distributed threads. Or do you want to wait until symbol after symbol has been treated individually in one kernel?

If one symbol is done it doesn't bother any cpu-kernel any more until your EA or indicator creates the next task.

What you can try is to start the next symbol only after the actual has been done - and you'll see how long it'll take.

 
Carl Schreiber:

I don't understand you problem!

The slow increase and slowdown of the cpu usage is most probably caused bay the latency the download of the quotes for a symbol causes. That means that all your threads do not start their cpu-usage (copyRates) at the same time and do not end at the same time!!

So all what you see is normal - I guess -  in times of parallel distributed threads. Or do you want to wait until symbol after symbol has been treated individually in one kernel?

If one symbol is done it doesn't bother any cpu-kernel any more until your EA or indicator creates the next task.

What you can try is to start the next symbol only after the actual has been done - and you'll see how long it'll take.

I want release Occupied CPU by CopyRates after any run CopyRates

in any moment one copyrates run not two copy . one copyrates use 3%(for example) from my CPU . now why my CPU is 30% usage after 10 time repeat copyrates ?  whereas just one copyrates run in moment

look this example 

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

      

   for( int i=0 ; i<TotallSymbolNumber ; i++ )
      {


        First time loop

        CPU Usage is 5%
        
        CopyRates(.....)
      
        CPU Usage is 8%        
        



        Now I want Release 3% and continue loop
      



        If cpu release , so this is happen :

      

        Second time loop

        CPU Usage is 5%

        CopyRates(.....)
      
        CPU Usage is 8%

        and release 3% again




        BUT If NOT CPU release this is happen :


        Second time loop

        CPU Usage is 8%

        CopyRates(.....)
      
        CPU Usage is 11%


        Third time loop

        CPU Usage is 11%

        CopyRates(.....)
      
        CPU Usage is 14%




        repeat and repeat and repeat... and my CPU is full...

      }

  
//---
   return(0);
  }


 

 
Ehsan Tavakoli:

I want release Occupied CPU by CopyRates after any run CopyRates

in any moment one copyrates run not two copy . one copyrates use 3%(for example) from my CPU . now why my CPU is 30% usage after 10 time repeat copyrates ?  whereas just one copyrates run in moment


 

Why ??? the best usage of a CPU is to have it at 100% all the time (for good usage of course). A CPU which is not working is just wasted.

Anyway, that's a compiler optimization, so if you don't want it, don't use a loop.

 
Alain Verleyen:

Why ??? the best usage of a CPU is to have it at 100% all the time (for good usage of course). A CPU which is not working is just wasted.

Anyway, that's a compiler optimization, so if you don't want it, don't use a loop.

you're right

But this code should always work . when i open metatrader i run my expert until close metatrader and always loop and copy rates .

so I don't have free CPU for another process and another cod  if this cod always use all CPU Capacity

 

I  should share my CPU between all program and manage my cpu capacity

Another program work slowly if this cod use all of my CPU  

Furthermore this cod not need this amount of CPU and this usage amount is overload and unreasonable 

If by use more CPU , Speed is fast too , that's  good .

But use all CPU & not work fast .

In start  , this cod by use 3% of CPU extremity of speed for copyrates is 1 symbol per second (almost in my pc) and after use all of CPU is not faster from 1 symbol per second and still copy 1 symbol in 1 second

CopyRates just need 3 or 4 or 5 percent for one copy , and in any moment just run one copyrates  , so why use more than 5% of CPU ? 

 
Ehsan Tavakoli:

you're right

But this code should always work . when i open metatrader i run my expert until close metatrader and always loop and copy rates .


Please explain what you are doing exactly ?

The code your provided get Daily rates on the 10 last candles. Only the current open daily candle is changing, so don't copy 10 candles but only 1.

Depending of your goal I am sure you could optimize your code to avoid this CPU issue.

 
Alain Verleyen:

Please explain what you are doing exactly ?

The code your provided get Daily rates on the 10 last candles. Only the current open daily candle is changing, so don't copy 10 candles but only 1.

Depending of your goal I am sure you could optimize your code to avoid this CPU issue.

Thanks Alain 

this cod and 10 candle is example  

I want check divergence always and alarm to me if any symbol have a condition 

for this i need have symbol rates and loop check & calculate 

Now i copy rates and calculate any symbol rates one by one and repeat this work

 
Ehsan Tavakoli:

Thanks Alain 

this cod and 10 candle is example  

I want check divergence always and alarm to me if any symbol have a condition 

for this i need have symbol rates and loop check & calculate 

Now i copy rates and calculate any symbol rates one by one and repeat this work

Sorry but I can't help with so vague information.

Good luck.

 
Alain Verleyen:

Please explain what you are doing exactly ?

The code your provided get Daily rates on the 10 last candles. Only the current open daily candle is changing, so don't copy 10 candles but only 1.

Depending of your goal I am sure you could optimize your code to avoid this CPU issue.

And still CPU usage is my issue (Concern) :)

And still i want free my CPU after any copyrates

Because i think it is unreasonable 

 
Ehsan Tavakoli:

And still CPU usage is my issue (Concern) :)

And still i want free my CPU after any copyrates

Because i think it is unreasonable 

CopyRates() is mql function, you don't have any way to "free" CPU or whatever. Only MQ can, did you write them ?

What you can do is optimize your code for your goal...up to you :-)

 
Alain Verleyen:

Sorry but I can't help with so vague information.

Good luck.

I write that cod ( check divergence ) and i write many mqh file for this work

I have problem just About high usage CPU on copyrates