Puzzle with time functions

Posted By: Zheka

Puzzle with time functions - 11/23/18 14:35

Dear All,

I am looking to understand why this script:
Quote:
function run()
{
BarPeriod=1;
LookBack=1;
Verbose=7;

if(is(INITRUN))
{
assetList("AssetsIB");
asset("EUR/USD");
}

if(!is(LOOKBACK))
{
var curDate=wdate(0);
printf("n curDate=%.5f,YMD=%i, TOD=%i, utcDOW=%i, estDOW=%i", curDate, ymd(curDate), tod(curDate), dow(curDate), ldow(EST,curDate));
}
}
Generates in TRADE MODE:
Quote:
57 Bars 2018-11-22..2018-11-22 generated
V 1.964 on Thu 18-11-22 11:10:58
EUR/USD 1.14041 0.00003 0.000 0.000 0.00010 1.00000 344.8333 1000.0 3000000.0

Lookback period (1 bars)

[56: Thu 18-11-22 16:10] 1.14045/1.140451.14028/1.14038 -0.000030000

End of lookback period

[57: Thu 18-11-22 16:11] 1.14041/1.140411.14041/1.14041 -0.000030000
curDate=43426.67431,YMD=20181122, TOD=0, utcDOW=4, estDOW=3

Why - according to Support- does a var variable curDATE gets passed as int to tod() and ldow()?

Any hints are much appreciated.
Posted By: jcl

Re: Puzzle with time functions - 11/23/18 14:56

Because the function parameters are ints, not vars.

http://manual.zorro-project.com/month.htm
Posted By: Zheka

Re: Puzzle with time functions - 11/23/18 15:15

As per manual:
Quote:
Offset: Optional offset of the bar for which the date or time is returned, to the current bar; or 0 for the current bar;
or NOW for the current PC time;
or when > 30000, a particular date in DATE format..
This used to work, and even now dow() returns the correct number...but not ldow()

Has this changed?
Posted By: Zheka

Re: Puzzle with time functions - 11/23/18 16:12

Or DATE - which is a var - gets typecasted to int?

This would explain why tod(DATE) returns 0, but not why ldow() returns the previous day..

But then this would mean that all time-returning functions do not really work when passed a DATE, and the manual creates wrong expectations...
© 2024 lite-C Forums