Download MetaTrader 5

declaring

To add comments, please log in or register
Dua Yong Rew
5485
Dua Yong Rew  

is it better to do this

void OnTick()
  {
   CTrade   m_Trade;
  }

 or

do it as global?

Which is better for performance? 

Alain Verleyen
Moderator
32774
Alain Verleyen  
doshur:

is it better to do this

 or

do it as global?

Which is better for performance? 

Certainly a global, but I haven't tested it. You can create a little EA and test both solutions with the Strategy Tester to see which is better for performance.
Dua Yong Rew
5485
Dua Yong Rew  
I think it should better perform. How can I test the performance in the strategy tester? 
Dua Yong Rew
5485
Dua Yong Rew  
Testing with CTrade declared inside OnTick()
2013.09.02 14:37:33 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 21360 ms (total bars in history 9856, total time 21500 ms)
2013.09.02 14:38:57 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 20156 ms (total bars in history 9856, total time 20297 ms)

Testing with CTrade declared on Global
2013.09.02 14:40:22 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 16343 ms (total bars in history 9856, total time 16484 ms)

2013.09.02 14:41:07 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 15015 ms (total bars in history 9856, total time 15156 ms)

 

Seems to be faster. So does this save me some money if I optimize my EA with the Cloud services? 

Alain Verleyen
Moderator
32774
Alain Verleyen  
doshur:
Testing with CTrade declared inside OnTick()
2013.09.02 14:37:33 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 21360 ms (total bars in history 9856, total time 21500 ms)
2013.09.02 14:38:57 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 20156 ms (total bars in history 9856, total time 20297 ms)

Testing with CTrade declared on Global
2013.09.02 14:40:22 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 16343 ms (total bars in history 9856, total time 16484 ms)

2013.09.02 14:41:07 Core 1 EURUSD,H1: 11915905 ticks (3645 bars) generated within 15015 ms (total bars in history 9856, total time 15156 ms)

 

Seems to be faster. So does this save me some money if I optimize my EA with the Cloud services? 

You will probably save 1 cent.
Dua Yong Rew
5485
Dua Yong Rew  
What else can I do to optimize performance? 
Alain Verleyen
Moderator
32774
Alain Verleyen  
doshur:
What else can I do to optimize performance? 
Your question is too wide. What's your real problem ?
Dua Yong Rew
5485
Dua Yong Rew  

no problem

just trying to optimise my EA performance in terms of optimization 

Dua Yong Rew
5485
Dua Yong Rew  

can anyone try print vs printf?

I notice using print is much faster 

Documentation on MQL5: Common Functions / Print
Documentation on MQL5: Common Functions / Print
  • www.mql5.com
Common Functions / Print - Documentation on MQL5
To add comments, please log in or register