ArrayCopyRates blows out CPU usage and hangs terminal

 

I am running this piece of code at the beginning of start() in an indicator on a 1H chart to ensure that M5 data is available for calculations.

If its not available from the broker then it should return and wait for the next tick.


I find that for most currency pairs this prevents the system from hanging with 50% CPU usage (dual processor). However,

for AUDUSD I still find that CPU usage climbs to a maximum in a few seconds and hangs the terminal.


I have searched for an answer to what is happening and can't find one.


ArrayCopyRates(dataArray, NULL, 5);
if(GetLastError()!=0) {
attemptCount++;
Comment("Attempts to get data= ", attemptCount);
if(attemptCount>MaximumAttemptsForData_) {
AllTradingStopped= TRUE;
}
return(0);
}


I am using WinXP on a fast Intel processor with 4GB of RAM. The broker is FXcbs.


Any ideas please because I've dried up!

 

Are you sure it's exactly ArrayCopyRates() that causes the problem?

I've had similar problems, but not with this function. I've found a solution, although I've not yet found the cause...

--> What is it, that soaks up all my RAM?

 
schnappi:

Are you sure it's exactly ArrayCopyRates() that causes the problem?

I've had similar problems, but not with this function. I've found a solution, although I've not yet found the cause...

--> What is it, that soaks up all my RAM?

Thanks Schnappi. Having read about your situation I think it became a problem when I have added the extra code to the main program.


However, I didn't get a blowout in RAM utilisation, just CPU time.


I'll try your solution and see what happens.


ps I totally agree, MT5 may solve this but present us with other interesting anomolies.

pps If you're tuning in Stringo, thanks for the program, it is a real asset.

Reason: