wait x ticks makes strategy tester loop

 

                             for (i=certainamountofticks;i>=1;i--)
                             {
                               Alert("Ticks to go ",i);
                               
                               while(RefreshRates()==false)  // To the new tick
                               {
                                  Alert("waiting");                  // Cycle delay
                               }   
                             }

Hi,

this code makes my EA loop until certain amount of ticks passes and it works fine.

The problem is in strategy tester. It makes the tester loop infinitly.

How can i make it work in tester as well?

Thanks.

                       

 

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. How can i make it work in tester as well?
    You can't. You must return from start() and count the number of times start() is called.
  3. and it works fine.
    And it uses all available CPU time both in the EA thread and in the GUI thread. You're probably missing ticks unless you have a fast enough processor.
 
maniam01:

Hi,

this code makes my EA loop until certain amount of ticks passes and it works fine.

The problem is in strategy tester. It makes the tester loop infinitly.

How can i make it work in tester as well?

Do it properly, count a tick each time start() is executed,  if you haven't had enough ticks   return(0); 
 
WHRoeder:

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. How can i make it work in tester as well?
    You can't. You must return from start() and count the number of times start() is called.
  3. and it works fine.
    And it uses all available CPU time both in the EA thread and in the GUI thread. You're probably missing ticks unless you have a fast enough processor.

The processor usage is 25% during testing (quad core) and few% during trading. i`m not missing ticks, i checked.
 
RaptorUK:
Do it properly, count a tick each time start() is executed,  if you haven't had enough ticks   return(0); 


I don`t want properly, i prefer by using RefreshRates, it`s more convinient in my EA.

So, RefreshRates in a loop will not work in tester?

Is there another way to count ticks without loop but using RefreshRates, that will work in tester too?

Thanks 

 
maniam01:


I don`t want properly, i prefer by using RefreshRates, it`s more convinient in my EA.

So, RefreshRates in a loop will not work in tester?

Is there another way to count ticks without loop but using RefreshRates, that will work in tester too?

Thanks 


yes,   every tick is old fresh tick you have from history data

newer history you won't get testing 

int start()
  {
   tick++;


 
 
maniam01:


I don`t want properly, i prefer by using RefreshRates, it`s more convinient in my EA.

So, RefreshRates in a loop will not work in tester?

Is there another way to count ticks without loop but using RefreshRates, that will work in tester too?

Thanks 


If you don't want to do it properly, that is your choice.  You should listen to RaptorUK and WHRoeder.

int max_ticks_to_wait = 50;   // choose whatever number you want
int current_tick_count = 0;

int start() {
   if (current_tick_count <= max_ticks_to_wait) {
      current_tick_count++;
      return (0);
   }
   else
      current_tick_count = 0;

   // the rest of your code here

   return (0)
}
 

RefreshRates() does nothing in the strategy tester, so you might wait forever. Neither does Alert(), so you have clear infinite loop with no option to break it. 

 
Ovo:

RefreshRates() does nothing in the strategy tester, so you might wait forever. Neither does Alert(), so you have clear infinite loop with no option to break it. 

 


Thank you all. It was helpfull.
 
maniam01:


I don`t want properly, i prefer by using RefreshRates, it`s more convinient in my EA.

So, RefreshRates in a loop will not work in tester?

Asked and answered. You must return in the tester. End of Thread.
 

Hi guys,

I know this thread is already a little bit old but I'm with the same problem as maniam01, and there is no start() function on my EA.  Was it replaced for OnTick() in newer versions of MT4 or something like that ?

I'm totally newbie on MQL4 and strugling to backtest my first EA, I'll appreciate any help.

 

Thanks in advance. 

Reason: