100% CPU USAGE ?!

 

After I attached my EA to some charts (4-7 charts), 100% CPU usage goes to Terminal.exe, other applications were slowed down to an unbearable extent. Does anybody know if anything is wrong with my EA. In my EA, there is NO dead loop, I cautioned not to use While -- do loop. Thanks.

 

Endless loop can be caused by error in "for" loop, too...

for( int i = 0; i <= 10; i--){

That loop never ends due to mistake: i-- should be i++

Or, there can be other problems...

An endless loop would show up with single chart/EA. More general performance problems
would show up as you add more charts/EAs.

When testing such problems set the priority of terminal.exe to "below normal" in TaskManager.

If MT4 runs wild, even with 100% CPU, other programs are higher priority and unaffected.

 
Place your code here.
 
marshall318:

After I attached my EA to some charts (4-7 charts), 100% CPU usage goes to Terminal.exe, other applications were slowed down to an unbearable extent. Does anybody know if anything is wrong with my EA. In my EA, there is NO dead loop, I cautioned not to use While -- do loop. Thanks.

I had this when my program wrote to an array element beyond the end of the array that really screwed things up. Also don't call custom indicators from an expert.
 

There is nothing intrinsically wrong with calling iCustom(), depending on the quality of the indicator called.

Writing past the end of an array will have indeterminate consequences.... that's a fact...

 
Ruptor:

I had this when my program wrote to an array element beyond the end of the array that really screwed things up. Also don't call custom indicators from an expert.
It's quite wrong and I consider you must know it! See What´s easier for the computer to calculate, with or without iCustom() function?
 

" I had this when my program wrote to an array element beyond the end of the array that really screwed things up"

I have some array writing code in my EA, it is very likely that the array writing code caused the problem. Please correct me if I have something wrong in the following:

static double ML_Signal[8];

ArrayInitialize(ML_Signal,88);
filename = Symbol() + "_Result.csv";
int handle = FileOpen(filename, FILE_CSV, ',');

if(handle>0)
{
FileSeek(handle,0,SEEK_SET); // Move the pointer to the beginning.
for (int pos = 0; pos <= 7; pos++)
{
ML_Signal[pos] = FileReadNumber(handle);
}
FileClose(handle);
}

Does it go beyond the end of the array?

Thanks

 
No, looks OK. Declaring array size 8 gives allocation for array index 0-7
 
Rosh:
It's quite wrong and I consider you must know it! See What´s easier for the computer to calculate, with or without iCustom() function?

Rosh, I would not waste time by lying. I have stated what I have experienced with arrays and custom indicator calls from an EA. A couple of months ago I posted an example dummy EA that called an empty Custom indicator to demonstrate the problem. Several times I have had custom indicators that work fine on charts without errors and yet will lock the computer when called from an EA. The solution I was given was to incorporate the indicators in the EA.

Reason: