![]() |
Metatrader using 40% of the CPU all the time when using EA The EA only runs real code every 15 minutes, between them it only runs this code (which is on start() function): if ( iTime(NULL, PERIOD_M15, 1) == last_start_time ) return(0); which makes the EA stop until the next tick. I put the EA on 15 pairs, and terminal.exe is constantly using 35-40% of the CPU (my processor is Intel Quad core Q6600 @ 2.40GHz). Is it normal? |
Nope, sounds like a memory leak possibly. When you start up the EA snap a pic of your windows task manager on performance tab... with the market open wait a few hours and then snap another picture of the windows task manager. Compare the two pics. Are you using more memory in the last pic than the first? If you are using more memory in the second pic than the first then that's your problem. (Right now I am only guessing) |
Inserted Code //+------------------------------------------------------------------+ //| testingotherscodeindi.mq4 | //| nubcake | //| | //+------------------------------------------------------------------+ #property copyright "nubcake" #property link "" #property indicator_chart_window #define cycles 1000000 int deinit() { Comment(""); return(0); } int init() { return(0); } int start() { int c; int tc, start1, start2, end1, end2, dummytick; datetime dummytime; start1 = GetTickCount(); for (c = 0; c < cycles; c++) if (Time[1] != Time[0]) dummytick = GetTickCount(); end1 = GetTickCount() - tc; Comment(dummytick); start2 = GetTickCount(); for (c = 0; c < cycles; c++) if (iTime(NULL, PERIOD_M15, 1) != Time[0]) dummytick = GetTickCount(); end2 = GetTickCount() - tc; Comment(dummytick); Comment("Time[]:\n", start1, " ", end1, " (", end1-start1, "ms)\niTime[]:\n", start2, " ", end2, " (", end2-start2, "ms)"); return(0); } something isn't right and more poking and prodding of your setup is required to isolate the problem... |
Thanks for the answers, but today I noticed that happens for 7-8 minutes and then the CPU use goes to 5-10% until the next M15 bar, which is the time to run all the code (a lot of loops). I guess there's no way to lower the CPU use right? Edit: I just noticed that the EA only runs all the code in those 15 minutes on the first pair I put the EA in, on the others it doesn't run all the code until the next bar appears. I don't know what to do now... Run a terminal.exe for each pair? |
not much else can really be said with just those few lines of code. |
1 Attachment(s) I agree with Nubcake... something is not right. Here's a pic of my task manager running 2 instances of meta trader with 1 ea on 1 pair on one and on the other running on more than 10 pairs with a piece of code that runs every tick and more than 2000 lines of code. FYI, Reason why I suspect memory leak is I've seen that issue before on my own rig and it's not instantaneous it builds over time. A memory leak in and of itself will cause cpu overloads as well as more and more memory usage as time goes on. If you restart the computer / EA then it starts all over again... that's why they call it a "leak". You will only get to the bottom of it by poking and prodding as Nubcake suggested. |
Thanks for the help, I changed my code to be (way) more efficient. As for the 5%-10% CPU use, it's because of a set of indicators I need to use with my EA. |
© Forex Factory