Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Edgar_Herrera), 1,110 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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