wait x ticks makes strategy tester loop

Back to topics list To post a new topic, please log in or register
avatar
8
maniam01 2013.03.20 22:32
 

                             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.

                       

 
avatar
13009
WHRoeder 2013.03.20 23:44 #
 

  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.

 
avatar
14167
RaptorUK 2013.03.20 23:46 #
 
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); 

 
avatar
8
maniam01 2013.03.20 23:57 #
 
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.

 
avatar
8
maniam01 2013.03.21 00:06 #
 
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 

 
avatar
2408
deVries 2013.03.21 00:36 #
 
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++;


 
 
avatar
352
GreenMoney 2013.03.21 00:45 #
 
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)
}

 

 

 

 
avatar
1111
Ovo 2013.03.21 08:48 #
 

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. 

 

 
avatar
8
maniam01 2013.03.21 18:08 #
 
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.
avatar
13009
WHRoeder 2013.03.21 19:46 #
 
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.
 
avatar
3
albericolima 2015.02.10 19:15 #
 

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. 

Back to topics list  

To add comments, please log in or register