Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
hour() return wrong number #480578
06/17/20 08:53
06/17/20 08:53
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

I have this code:
Code
#include <default.c>

string datetime(){
    return strf("%04d-%02d-%02d %02d:%02d", year(),month(),day(),hour(),minute());
}

function run()
{

    BarPeriod = 15;	// 15 min
    LookBack    = 0;
    assetList("Assets4");
    asset("EUR/USD");
    var dDateD=wdatef("%Y-%m-%d %H:%M", datetime());
    printf("\n%s is %d",datetime(),utm(dDateD));
}


real hour UTC is 8 but fce hour return 9

Where is problem ( see the picture )

Attached Files Snímek obrazovky 2020-06-17 v 13.49.16.png
Re: hour() return wrong number [Re: Grat] #480581
06/17/20 09:38
06/17/20 09:38
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
hour() is not the current time. It's the time stamp of the current bar.

For the current time, use hour(NOW).

Re: hour() return wrong number [Re: Grat] #480582
06/17/20 09:42
06/17/20 09:42
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Yes, I know, but is in future. Only for first bar. For next one is OK

Last edited by Grat; 06/17/20 09:42.
Re: hour() return wrong number [Re: Grat] #480587
06/17/20 10:27
06/17/20 10:27
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
From the manual: "All date and time functions return 0 resp. invalid values in the initial run of the strategy since the bars and date ranges are not set up yet."

The time functions assume that the bar just ended. That's why you got the bar end time in the INITRUN, which is not in sync with the bars. In further runs the bar timestamp is just the current time.

Re: hour() return wrong number [Re: Grat] #480589
06/17/20 11:03
06/17/20 11:03
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Thank's,

every days is I learn new ... laugh


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1