datetime TimeCurrent( | ) |
Note: At the testing, the last known server time is modelled.
datetime TimeCurrent( | ) |
Note: At the testing, the last known server time is modelled.
Thanks. Just to be clear when you say the server time, is this the same as the original date and time for the orignal historical data?
Will lookin to Timecurrent function.
thanks again
All time functions work as expected: They refer to the time in the chart you are testing (and not the current time) or you could never backtest strategies that make decisions at certain times.
Maybe the timestamps in your downloaded history data originated from a different time zone (unfortunately they all can refer to whatever time zone they want (and not even specify it) instead of always using UTC) and then all times in your downloaded data are shifted by a few hours relative to your broker's original data and this is the reason you are getting strange results.
mcguinnxx, you can edit a post by pressing the 'Edit' button that appears in the upper-right corner of your post... (I deleted your blank posts).
Gordon thks for deleting the blank post.
All help much appreciated. Thanks. I know I must be doing something wrong or stupid - so go easy! Below is a piece of test code I wrote to ensure I understand the functions. What I can't understand is why it prints times other than those in the if statement, e.g, 05:20, 23.59, etc Any suggestions
HR =
TimeHour(TimeCurrent());
MIN = TimeMinute(TimeCurrent());
SEC=TimeSeconds(TimeCurrent());
{
if(HR == 8 && MIN == 1 && SEC == 1)
Print("HR ", HR);
Print ("MIN ", MIN);
Print ("SECs ", SEC);
mcguinnxx:
I am trying to devveop a back test that trades at a specific time of the day.
int DOW = TimeDayOfWeek(now), /* https://forum.mql4.com/33851 // reports DayOfWeek() always returns 5 in the tester. No refresh?*/ DayMask = 1 << DOW; // #define DAYS_MAX 0x3F // 1<<6-1=63. (S-F) //extern int Days.Mask = 55; // Not Wed if (Days.Mask & DayMask == 0){ rsn="|Day="+DOW; return;} //extern double TradeHr.UTC.Start = 7.3; // London-1 //extern double TradeHr.UTC.End = 12.9; // NY open // int tradeSec.UTC.start = 3600*TradeHr.UTC.Start-86400, // tradeSec.UTC.end = 3600*TradeHr.UTC.End -86400; int hrBeg = (now-tradeSec.UTC.start)%86400, hrEnd = (now-tradeSec.UTC.end )%86400; if (hrBeg > hrEnd){ rsn="|HR"+DoubleToStr(hrBeg/3600.-24.,2); return;}
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to devveop a back test that trades at a specific time of the day. I have downloaded and created tick data as per previous posts (many thanks) and am getting totally confusing results. I can only conclude it is my lack of understanding of how time functions operate.
Can someone point me to an article or post that explains how date and time functions operate in the Strategy tester. Do these functions work off the historical data or off the local time (my pc)? If off the local time how do I refer back to the time of the actual historical data. Hope this makes sense.
All help much appreciated.