100% CPU using CopyRates for many symbols

Rafael Garcia  
Good night people,
I am developing a robot to read the last closing value of many assets.
Test to obtain or close 1000 different assets, but the MT5 is very slow and uses 100% of the CPU. Even stopping or robot, the MT5 continues to allocate 100% of the CPU.
If you run a test with 200 assets, it works normally. You already use the first 200 assets, after the next execution of OnTimer () it captures another 200 assets ... but still it allocates 100% of the CPU.
I am using "SymbolSelect (vNomeSymbol [i], false)" to try to remove the memory, but it is no use.

Can someone help me to CLEAN / DEPELL or cache the CPU?


        Rows = 1000;

        for (i=0; i<Rows; i++) 

        {     

        Print( i, " - Contador");             

            if (vNomeSymbol[i] != "")

               {

                  MqlRates velas[]; 


                  CopyStatus = CopyRates(vNomeSymbol[i],_Period,0,1,velas);

                  if(CopyStatus != -1){

                     ArraySetAsSeries(velas,true);   

                     vUltimo_valor = velas[0].close;

                     Print( vNomeSymbol[i], " : Ativo 1 Atualizado:", vUltimo_valor );                           

                  } else {

                     vnomeRetirar = vnomeRetirar+ ";"+ i +";"+ vNomeSymbol[i]; 

                     Print( vNomeSymbol[i], " : Array de Ativo não encontrado na vela" );

                  } 


                  if ( SymbolSelect(vNomeSymbol[i], false ) == true ) {

                     Print( vNomeSymbol[i], " : Ativo removido do Observador de Mercado" );

                  } else {

                     Print( vNomeSymbol[i], " : Ativo Permanece no Observador de Mercado" );                     

                  }

               }

        }


scur  

sometimes when the CPU load is too great it freezes

to avoid that i, personally, use a program called Process Lasso to avoid that

it keeps the processor at 99.99% and i can navigate, watch movies, etc without freezing

tried also to have 2 different MT5 clients running optimization at the same time, the result was awesome, never freezed or lost windows functionality


check the net for it, or a similar program. in the long run you get more done as the processor never freezes

hope it helps

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
Reason: