EA to run just once a day

To add comments, please log in or register
Arbubu
210
Arbubu  

I'd like to test a strategy to run only at 6 every morning. I think I can do it with the timer OK, but it's still incredibly slow to test, maybe half an hour to do a month.. Can I do something to speed it up? Here's the code I have:

int OnInit()

  {

//--- create timer

   

   MqlDateTime hari;

   TimeGMT(hari);

   EventSetTimer((6-hari.hour)*3600-hari.min*60-hari.sec);

   

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//--- destroy timer

   EventKillTimer();

   

  }


  

 

 void OnTimer()

  

  {EventSetTimer(3600*24);

  MqlDateTime hari;

   TimeGMT(hari);

   Print(hari.day);

  }

Eleni Anna Branou
Moderator
6586
Eleni Anna Branou  

Use the SRC button to post your code.


Arbubu
210
Arbubu  
Eleni Anna Branou:

Use the SRC button to post your code.



int OnInit()
  {
//--- create timer
   
   MqlDateTime hari;
   TimeGMT(hari);
   EventSetTimer((6-hari.hour)*3600-hari.min*60-hari.sec);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
   
  }

  
 
 void OnTimer()
  
  {EventSetTimer(3600*24);
  MqlDateTime hari;
   TimeGMT(hari);
   Print(hari.day);
  }
  
Arbubu
210
Arbubu  

It's running at the moment and taking about six minutes to run each day even though I only want it to look at prices at one moment. I've used MT4 in the past and it was quick with that. What's happened?

honest_knave
Moderator
2302
honest_knave  
Arbubu:

I'd like to test a strategy to run only at 6 every morning. I think I can do it with the timer OK, but it's still incredibly slow to test, maybe half an hour to do a month.. Can I do something to speed it up? Here's the code I have:


Are you using this code in Strategy Tester?

If so, please read this post.
Arbubu
210
Arbubu  
honest_knave:

Are you using this code in Strategy Tester?

If so, please read this post.

OK, so the timer won't work in the strategy tester. But still, why is the testing SO slow? If it's going to take three hours to run a test I'll never get there. I would need to run it multiple times, ironing things out.

Should I just go back to MT4? Can I just go back to MT4?

Alain Verleyen
36050
Alain Verleyen  
Arbubu:

OK, so the timer won't work in the strategy tester. But still, why is the testing SO slow? If it's going to take three hours to run a test I'll never get there. I would need to run it multiple times, ironing things out.

Should I just go back to MT4?

The timer IS working in MT5 Strategy Tester.

The code you posted is not "SO slow" :

2018.01.24 09:34:33.147 Core 1 EURUSD,H1: 32301546 ticks, 4913 bars generated. Environment synchronized in 0:00:00.078. Test passed in 0:00:16.562 (including ticks preprocessing 0:00:04.141).

2018.01.24 09:34:33.147 Core 1 EURUSD,H1: total time from login to stop testing 0:00:16.640 (including 0:00:00.078 for history data synchronization)

That's 16 seconds. 1 year data on every tick mode.
Alain Verleyen
36050
Alain Verleyen  
Arbubu:

It's running at the moment and taking about six minutes to run each day even though I only want it to look at prices at one moment. I've used MT4 in the past and it was quick with that. What's happened?

What EXACTLY is taking 6 minutes to run ?

Documentation on MQL5: MQL5 programs / Testing Trading Strategies
Documentation on MQL5: MQL5 programs / Testing Trading Strategies
  • www.mql5.com
The idea of automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
To add comments, please log in or register