[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Current Day! Int()



PureBytes Links

Trading Reference Links

Steve,

I tried out various date calcs including possible use of 3 digit code for
year (see below). It seems to me there is at least one (probably more) bugs
in MS floating point conversion routines. Looks like any variations of date
calculation which result in an odd number get incorrect answer (looks like
MS routines are missing/dropping least significant bit of binary mantissa).
When you plot your original calcs as an indicator you can see value is
always even.

The code below was a quick attempt to workaraound using a 3 digit year code
i.e. 1999=199,2000=200,2001=201 etc.

{test date calc rtn}
DOM:=DayOfMonth();
MON:=Month()*100;
Y1:=100*(Int(Year()/1000));
Y2:=100*(Frac(Year()/100));
y1;
y2;
Y3:=y1+y2;
y3;
Int(y3);
y3*100;
y3*1000;
y3*10000;

But if you plot this and look at data window values for plott for years
2001, 2000, and 1999 you will see it does not work correctly  because MS is
storing all values as floating point i.e. INT() does not really return true
integer.

Given these failings I cannot see a workaround that is going to work. What
MS Formuls Language really needs is the facility to type cast variables plus
a set of functions to convert between types (and strings ideally).

John

----- Original Message -----
From: "Steve Brann" <steveb@xxxxxxxxxxx>
To: <metastock@xxxxxxxxxxxxx>
Sent: Thursday, May 03, 2001 10:06 AM
Subject: RE: Current Day! Int()


> Thanks Lionel
>
> Never spotted the INT() function - does not work sadly but it did give me
> some hope for a short while.
>
> Concatenating the year from 2001 to 01, for example, does not work either
as
> it is not millennium friendly. 1999, 2000 & 2001 would order incorrectly.
>
> I can normally design a work around solution for challenges stemming from
> MS's idiosyncrasies but this one really has me stumped.  I alerted
technical
> support yesterday and I am sure they are reading this list, so I shall
keep
> you informed on their response.
>
> As always,
>
> Steve
>   -----Original Message-----
>   From: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Lionel Issen
>   Sent: 03 May 2001 02:24
>   To: metastock@xxxxxxxxxxxxx
>   Cc: support@xxxxxxxxx
>   Subject: Re: Current Day!
>
>
>   page 250 of V7.xx defines an integer function.  Perhaps defining each
> number as an integer would help
>
>   Try something like this:
>   DOM:= integer(DayOfMonth());
>   MON:= integer(Month());
>   YR:=Integer(Year());
>
>   Let me know if it works or not.
>
>
>   Lionel Issen
>   lissen@xxxxxxxxx
>     ----- Original Message -----
>     From: neo
>     To: metastock@xxxxxxxxxxxxx
>     Sent: Wednesday, May 02, 2001 4:22 PM
>     Subject: RE: Current Day!
>
>
>     Perhaps you could combine the 2 with and If function?
>
>     neo
>
>       -----Original Message-----
>       From: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of C.S.
>       Sent: Wednesday, May 02, 2001 3:39 PM
>       To: metastock@xxxxxxxxxxxxx
>       Subject: Re: Current Day!
>
>
>       I tried the equation backwards to see if DDMMYYYY would work.
>
>       DOM:=DayOfMonth();
>       MON:=Month();
>       YR:=Year();
>       YR+(MON*10000)+(DOM*1000000)
>
>       It works for the first day but not for the days at the end of the
> month.
>       for 4/30/2001 I get 30042000 and not 30042001.
>
>       -Corey
>         ----- Original Message -----
>         From: Steve Brann
>         To: metastock@xxxxxxxxxxxxx
>         Sent: Wednesday, May 02, 2001 9:36 AM
>         Subject: RE: Current Day!
>
>
>         Hi L
>
>         Thanks. Version 7.02 end of day version.
>
>         I am also getting results such as 20001032 (Oct 32nd, 2000) when I
> should be getting 20001101 (Nov 1st,2000).  Interesting eh?
>
>         Steve
>           -----Original Message-----
>           From: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Lionel Issen
>           Sent: 02 May 2001 14:52
>           To: metastock@xxxxxxxxxxxxx
>           Subject: Re: Current Day!
>
>
>           Steve:
>           This is an excellent concise method.
>
>           What version are you using?
>
>           Lionel Issen
>           lissen@xxxxxxxxx
>             ----- Original Message -----
>             From: Steve Brann
>             To: metastock@xxxxxxxxxxxxx
>             Sent: Wednesday, May 02, 2001 7:05 AM
>             Subject: Current Day!
>
>
>             Hi
>
>             I use the following in my explorations to denote the date of
the
> last price data in the format yyyymmdd;
>
>             DayOfMonth()+(Month()*100)+(Year()*10000)
>
>             However, this fails if the date is the first of the month such
> as March 1st 2001, instead of getting 20010301 I get 20010300!
>
>             Has anyone else experienced this and if so is there a
solution?
> By the way, using DayOfMonth() on its own produces 01.
>
>             Thanks in advance
>
>             Steve
>