lukins:
What would you do if your Script/EA/Indicator overloads the CPU while running?
What would you check first, what optimization would you apply?
Especially if there is an endless loop in Script..
optimizations are irrelevant, the code is broken, fix the code, optimize is the last thing to do after it's working correctly.
Put a Print statement at the top of every function like "function name start" and before any returns like "function name end 1."
run it and when it hangs the last line will tell you where and who called it. Comment out the print statements and add more inside the function's loops including variables and values. run and isolate.
optimizations are irrelevant, the code is broken, fix the code, optimize is the last thing to do after it's working correctly.
Put a Print statement at the top of every function like "function name start" and before any returns like "function name end 1."
run it and when it hangs the last line will tell you where and who called it. Comment out the print statements and add more inside the function's loops including variables and values. run and isolate.
Thanks for reply. If I understand correctly, you recommend me to find out the code that forces CPU load, right? I've already put such Print statements for almost every logical code part, but how can I determine which one uses more CPU?
Thanks for reply. If I understand correctly, you recommend me to find out the code that forces CPU load, right? I've already put such Print statements for almost every logical code part, but how can I determine which one uses more CPU?
Look at timestamps. Most EA operations are CPU-bound, so if you don't Sleep() inside or write to file then this can help measuring how long your code executes. You can also try to create use some dll that will count milliseconds for you if timestamps are not enough.
--
Luke
ChartsAccess.com - MetaTrader charts in any phone.
Look at timestamps. Most EA operations are CPU-bound, so if you don't Sleep() inside or write to file then this can help measuring how long your code executes. You can also try to create use some dll that will count milliseconds for you if timestamps are not enough.
--
Luke
ChartsAccess.com - MetaTrader charts in any phone.
I see. Thanks for advice.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
What would you do if your Script/EA/Indicator overloads the CPU while running?
What would you check first, what optimization would you apply?
Especially if there is an endless loop in Script..
Thanks