MetaTrader (terminal.exe) goes to 95% CPU utilization

 
Hi,

I have intermittently seen problems with the terminal.exe process. There are times when my custom indicators works when dragged onto a chart. Then there are times when the CPU spikes to 98% as soon as I drag the custom indicator to the chart (without making any changes to it). Once the CPU goes to 98% utilization, control is never returned back to the terminal.exe process. I have to end up killing the process to proceed.

Now, I have my MetaTrader client in a bad state as when I double click on the MetaTrader icon, it immediately goes to 95% cpu utlization and doesn't display the client.

1) Has anyone else see this behaviour?
2) How can I debug this behaviour?
3) I suspect that MetaTrader has in its setting to load the last chart with my indicator on it. How do I reset this before opening MetaTrader?
4) Can the creators of MetaTrader care to comment on how to avoid this scenario in the future?

I have battled with this issue in the past and the only solution I've found to this would be to uninstall and reinstall MetaTrader or find a new machine to install MetaTrader. This is becoming very frustrating as I'm looking for a reliable platform to test our strategies.

Please advice.

Thanks
syrndr
 
Check your custom indicators.
 
Check your custom indicators.


1) What should I be looking for in my custom indicator?
e.g. processing too many bars?
e.g. switching time periods within my indicators?

2) Also, how can I now start my MetaTrader client without having to uninstall and reinstall the whole thing.

Thanks
syrndr
 
You can remove this custom indicator (mq4 and ex4) from experts\indicators folder to another folder to storage
One question. Are string arrays used in your custom indicator?
 
You can remove this custom indicator (mq4 and ex4) from experts\indicators folder to another folder to storage
One question. Are string arrays used in your custom indicator?


Hi Slawa,

No string arrays are being used in the custom indicators.

Here is a list of things that I am using.

1) GlobalVariableGets and GlobaVariableSets
2) Static variable
3) Several print statements for debugging purposes
4) I do have about 9 if structures nested in my logic

I find that sometimes I can run the analysis on 1 bar and at other times, it freezes on 1 bar.

Thanks
syrndr
 
Hi Slawa,

By the way, I am running MetaTrader inside a Virtual Machine (VMWARE). Not sure if this makes a difference?

Thanks
syrndr
 
Check the shown bars in chart that this is not a to high value over 200000 better ist somethink like 50000 if not need more

and check the arrays elemnts that you dont have initialisate them with to much elemnts like 100000
 
Hi,

Thought I post this.

I figured out my problem.

It turns out that I was recursively calling 2 libraries and hence it was utilizing my CPU at 95%.

E.g. I had the following 2 files, HelperA.mq4 and HelperB.mq4

HelperA was importing HelperB and HelperB was importing HelperA. Hence the recursion.

I've refactored the code and it works on my machine.

An interesting observation though is that this recursion works on machines with Dual Cores but my single core machine can't handle this.

Thanks
syrndr
Reason: