• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 9:20am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 9:20am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Metatrader is running slow. Taking 50%CPU 25 replies

CPU usage increasing over time 7 replies

MetaTrader is running slow: Taking 100% of CPU 6 replies

EA is using 100% CPU in MetaTrader 4 10 replies

Metatrader 4 99% CPU Usage 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Metatrader using 40% of the CPU all the time when using EA
Exit Attachments
Tags: Metatrader using 40% of the CPU all the time when using EA
Cancel

Metatrader using 40% of the CPU all the time when using EA

  • Post #1
  • Quote
  • First Post: Sep 11, 2012 8:07pm Sep 11, 2012 8:07pm
  •  Jasus
  • | Joined Jun 2010 | Status: Portuguese Escudo Trader | 303 Posts
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?
  • Post #2
  • Quote
  • Sep 11, 2012 10:12pm Sep 11, 2012 10:12pm
  •  pip_seeker
  • | Joined Dec 2007 | Status: IF YOU SEE SMOKE, RUN! | 1,206 Posts
Quoting Jasus
Disliked
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?
Ignored

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)
 
 
  • Post #3
  • Quote
  • Edited 2:11am Sep 12, 2012 1:56am | Edited 2:11am
  •  nubcake
  • Joined Oct 2009 | Status: >Apocalypto< for Deputy PM | 2,918 Posts
Quoting Jasus
Disliked
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?
Ignored
i wouldn't be testing against iTime each tick. shouldn't make a grand difference, but still i wouldn't do that. you are better-off within your code block calculating the next specific time to always be testing against... then you can just if (time[0] >= whatevertime) { do some shit, and calc next whatevertime }

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);
}
this bit of junk code shows on my platform that iTime does cost more cycles than a simple Time[] test. on my system the cost is insignificant, but perhaps on your platform something hokey is going on. perhaps you have some other piece of code running with a similar iSomeFunc calls that are the problem. if you were happy-enough to use the code you have shown here you are probably happily doing something somewhere else really inefficiently and slowing your terminal down without realizing it.

something isn't right and more poking and prodding of your setup is required to isolate the problem...
 
 
  • Post #4
  • Quote
  • Edited 6:49am Sep 12, 2012 6:25am | Edited 6:49am
  •  Jasus
  • | Joined Jun 2010 | Status: Portuguese Escudo Trader | 303 Posts
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?
 
 
  • Post #5
  • Quote
  • Sep 12, 2012 7:05am Sep 12, 2012 7:05am
  •  nubcake
  • Joined Oct 2009 | Status: &gt;Apocalypto&lt; for Deputy PM | 2,918 Posts
Quoting Jasus
Disliked
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?
Ignored
your code sounds all kinds of busted. it sounds like it's triggering, getting caught in unnecessary loops and hanging your terminal to some degree or another, and then you aren't updating your vals to have it trigger on the next period. i think you need to do an overhaul and attack whatever it is you are trying to do from a different, more efficient, angle.

not much else can really be said with just those few lines of code.
 
 
  • Post #6
  • Quote
  • Sep 12, 2012 7:10am Sep 12, 2012 7:10am
  •  pip_seeker
  • | Joined Dec 2007 | Status: IF YOU SEE SMOKE, RUN! | 1,206 Posts
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.
Attached Image
 
 
  • Post #7
  • Quote
  • Last Post: Sep 17, 2012 11:38am Sep 17, 2012 11:38am
  •  Jasus
  • | Joined Jun 2010 | Status: Portuguese Escudo Trader | 303 Posts
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.
 
 
  • Platform Tech
  • /
  • Metatrader using 40% of the CPU all the time when using EA
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023