In backtest OnTimer() not performs - page 2

 

if very easy to create your own timer in the onTick method. just create a date variable to save the time. the timer will refresh on each new chart bar. feel free to replace PERIOD_M15, with PERIOD_M1, PERIOD_M30, PERIOD_H4, or whatever timer you want.

datetime Q15_Minute_Timer;

 if (Q15_Minute_Timer < iTime(Symbol(),PERIOD_M15,0))

  {

    Q15_Minute_Timer = iTime(Symbol(),PERIOD_M15,0);

    // whatever you want to do every 15 minutes

  }

 
Isho888:
MT4 OnTick()  is for Expert Advisor and not for Indicators
 
Isho888: MT4 OnTick()  is for Expert Advisor and not for Indicators

Wrong, it works fine in both. The only exception IIRC is indicators called by iCustom.

Files:
 
Julian Joseph #:

é muito fácil criar seu próprio timer no método onTick. basta criar uma variável de data para economizar tempo. o cronômetro será atualizado a cada nova barra do gráfico. sinta-se à vontade para substituir PERIOD_M15 , por PERIOD_M1, PERIOD_M30, PERIOD_H4 ou qualquer temporizador que desejar.

data e hora Q15_Minute_Timer;


your answer was brilliant.

Can I contribute to it?

static datetime Q15_Minute_Timer;

 if (Q15_Minute_Timer < iTime(Symbol(),PERIOD_M15,0))

  {

    Q15_Minute_Timer = iTime(Symbol(),PERIOD_M15,0);

    OnTimer();

  }
 
William Roeder #:

The tester doesn't run in real time, you can speed it up (32x,) and you can pause the creation of ticks and you can skip all ticks for a bar. How should the period of OnTimer change for those three scenarios?

Not likely to every run in the tester. Just check in OnTick for the tester and do the functionality. Same as Chart Event For MT4 Backtester (Migel) - MQL4 forum

Sorry, I don't want to be a smart ass but I don't understand the reasons why timer events are not possible for backtesting. 

Technically a timer event should not largly differ from a tick event with a fixed time interval.  As you know the period of the timer event, It's pure math to pre compute all possible timer events for a given time span and treat them like you treat ticks for pause and skip. The period lentgh itself should never change after initialization. 

Regarding Speed up32x: What happens when the tick frequency is to fast to speed up? In case the timer event frequency is restricted by hardware, just print a warning and set a predefined minimum period time (tested against minimum hardware requirements) which is applicable to speed up x32. This special case would not be an exact representation of the real time scenario, but it is ways better than no solution at all. 


Or do I miss something? If it's about budget and man power you have my full understanding :) 

 
sonaht #:

Sorry, I don't want to be a smart ass but I don't understand the reasons why timer events are not possible for backtesting. 

Technically a timer event should not largly differ from a tick event with a fixed time interval.  As you know the period of the timer event, It's pure math to pre compute all possible timer events for a given time span and treat them like you treat ticks for pause and skip. The period lentgh itself should never change after initialization. 

Regarding Speed up32x: What happens when the tick frequency is to fast to speed up? In case the timer event frequency is restricted by hardware, just print a warning and set a predefined minimum period time (tested against minimum hardware requirements) which is applicable to speed up x32. This special case would not be an exact representation of the real time scenario, but it is ways better than no solution at all. 


Or do I miss something? If it's about budget and man power you have my full understanding :) 

This is an old topic. You misunderstood.

Timer events are processed in backtests. They are just not "real-time", they are triggered according to the simulated time of the backtest.

The same is true for ticks events by the way.