How to know the time hh:mm at backtesting in higher timeframes

 

Hello.


I can't get the correct time at backtesting, for example if I'm at 4H timeframe I only can get the datetime when the bar opened (with Time[0]) but not the current time (at the backtesting, not local or server time).


I have tried to use iTime function to get the minutes with the 1M period... but I think backtesting can't get the information of another timeframes.


Do you know if there is a way to get tick by tick the time hh:mm in the simulation?


Thank you.

 

TimeCurrent shows the correct time when it's used in an EA, not when is used in a indicator dropped in a EA in backtesting. I think, it's fixed.

 

I also fell into this trap now, what was your way of fixing/getting around this issue?

thks,

egi

 

CurrentTime() is the time of the tick

Time[0] is the time of the chart bar start

iTime(NULL, TF, iBarShift(NULL, TF, X) ) is the time the TF bar started that includes X

In the tester, you can not get bar 0 values (except time/open) for other TFs

 

Hi,

In backtest, how to get the current time, I mean the real current time, like 2012 Aug 4 12:03pm? I use TimeLocal() and it just shows me the time of the current bar of the backtest. Thanks!

 
lingwuchung:

Hi,

In backtest, how to get the current time, I mean the real current time, like 2012 Aug 4 12:03pm? I use TimeLocal() and it just shows me the time of the current bar of the backtest. Thanks!


LOL well you do a backtest and you look same time at the clock in your home and you have the time of that moment then you also have to check the date of today and you get your real current time .... So forget using TimeLocal() it won't give you your real current time, like 2012 Aug 4 12:03pm (time of this moment)
 

TimeLocal() " Note: At the testing, local time is modelled and is the same as the modelled last known server time. "

Why would you need local time during a backtest on historic data ?

 
RaptorUK:

TimeLocal() " Note: At the testing, local time is modelled and is the same as the modelled last known server time. "

Why would you need local time during a backtest on historic data ?

Hi, because I want to time how long the backtest has run. Say if I the backtest with the same data has been running for 30 mins before as the benchmark, and after I've made some changes it has become 45 mins, there is something wrong.

It won't be possible for me to sit and watch and time when the backtest has finished every time.

 
lingwuchung:

Hi, because I want to time how long the backtest has run. Say if I the backtest with the same data has been running for 30 mins before as the benchmark, and after I've made some changes it has become 45 mins, there is something wrong.

It won't be possible for me to sit and watch and time when the backtest has finished every time.

Write a file from init() and write a different file from deinit() . . . then you have the start and finish times for the run.
 
RaptorUK:
Write a file from init() and write a different file from deinit() . . . then you have the start and finish times for the run.

Genius!!!!!!!!!!!!!!!!!
 
    int     startWaitingTime    = GetTickCount(),   // Remember start time.
:
    int delaySeconds = (GetTickCount() - startWaitingTime)/1000;
Reason: