Improve EA efficiency

To add comments, please log in or register
Ning Liu
261
Ning Liu  

I am running EA on my home computer, everytime when I hear the heavy fan sound from the computer, I am worry about its health.

Is there anyway can improve the EA efficiency?


original code:

for(int i=0; i<OrdersTotal(); i++)


I am using below, instead of call OrderTotal() for each i.

int _ordertotal=OrdersTotal();

for(int i=0; i<_ordertotal; i++){


My intention is to reduce the procedure for the EA to call server, will this help to improve the efficiency and stability of EA?

Dua Yong Rew
5437
Dua Yong Rew  
Not too sure about that but I'm sure if you get what you need and call for a break in the loop will benefit performance
Ning Liu
261
Ning Liu  
Good point!
In OnTick(), can i skip one tick for every two tick to do operation? This reduce half workload. Anyone tried it before?
Fernando Morales
651
Fernando Morales  
Ning Liu:

I am running EA on my home computer, everytime when I hear the heavy fan sound from the computer, I am worry about its health.

Is there anyway can improve the EA efficiency?


original code:

for(int i=0; i<OrdersTotal(); i++)


I am using below, instead of call OrderTotal() for each i.

int _ordertotal=OrdersTotal();

for(int i=0; i<_ordertotal; i++){


My intention is to reduce the procedure for the EA to call server, will this help to improve the efficiency and stability of EA?

I think there is no measurable difference in CPU use for the code you posted.

By chance, is you computer a laptop?

Ning Liu
261
Ning Liu  
Fernando Morales:

I think there is no measurable difference in CPU use for the code you posted.

By chance, is you computer a laptop?

Yes, i use laptop. I feel the bottle neck is the connection between computer and server. That is why unless use broker’s VPS, other vendor cannot improve at all.

For every i, i call OrderTotal(), i suppose this has to communicate with server. That is where the breakdown may occur.
Fernando Morales
651
Fernando Morales  
Ning Liu:
Yes, i use laptop. I feel the bottle neck is the connection between computer and server. That is why unless use broker’s VPS, other vendor cannot improve at all.

For every i, i call OrderTotal(), i suppose this has to communicate with server. That is where the breakdown may occur.

It is expected the laptop cpu fan to spin up as soon as there is an increase in CPU load. This is totally normal because the fan is usually off at idle.

OrdersTotal() does not connect to the server. 

As far I understand, Metatrader only connects to the server when using OrderSend(), OrderModify(), OrderClose() and OrderDelete(). If there is a big connection delay between your metatrader and the server you should see errors like trade context busy or requotes.

Anthony Garot
1843
Anthony Garot  
Ning Liu:
Good point!
In OnTick(), can i skip one tick for every two tick to do operation? This reduce half workload. Anyone tried it before?

If you don't need every tick for your strategy, then definitely skip the ones you don't need.

For example, some strategies only enter or exit at the beginning of a new bar. If this works for you, there are plenty of posts about detecting the start of a bar on this forum.

Ning Liu
261
Ning Liu  
Anthony Garot:

If you don't need every tick for your strategy, then definitely skip the ones you don't need.

For example, some strategies only enter or exit at the beginning of a new bar. If this works for you, there are plenty of posts about detecting the start of a bar on this forum.

Thank you for your reply.

That good point. Most of my orders are actually pending orders, all prices are pre-calculated grid, surround the current price, the initial purpose was to minimize the OrderSend() error and slippage. hence I don't need every tick.

To add comments, please log in or register