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

Re: [amibroker] DateTime() and DateTimeToStr question



PureBytes Links

Trading Reference Links

Andy

You are on the right track... but need some additional arithmetic.

The datetime() function returns a format that is rather hard to work with.

Try using DateNumber() and TimeNumber() functions. They are simpler because
thay only deal with date or time.

You have to watch out for exceeding the permitted values when adding the
additional time you compute.

Example:

Timenum() = 105345  for 10:53:45 (AM).  If you add 15 minutes to this (1500,
based on format used by TimeNum()) you will get 106845 which is bad because
it represents 10 hrs 68 min 45 sec. The 68 min term is obviously bad, but
some arithmetic can correct it to be 110845.

You may actually want to use the Now() function to get actual current time,
or the hour(), Minute(), Seconds() functions as they may make the arithmetic
a bit easier.

Study these function and understand the formats for the function you want to
use. The task is a bit messy, but pretty straight forward.




----- Original Message ----- 
From: "Andy Davidson" <AndyDavidson@xxxxxxxxxxxxx>
To: "Amibroker Yahoo Group" <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, July 04, 2006 11:03 AM
Subject: [amibroker] DateTime() and DateTimeToStr question


> I'm trying to use the DateTime() function in the Title of an indicator
> to show what the *predicted future date/time* of an event might be.
> Before anyone groans(!) I'm not a complete novice and aware that my data
> cannot predict the future... :-)
> However, I have an indicator which plots, amongst other things, a sine
> wave and I would like the Title to tell me what the date/time will be
> when the next peak or trough will occur based on the currently plotted
> wavelength.
> Here is the relevant part of the code that I came up with before I hit
> the brick wall
> (the "bars" variable is calculated previously in the code as the number
> of bars beyond the last bar in the chart where the peak or trough will be)
>
> nextDateTime =  LastValue(DateTime()) + bars*Interval() ;     (I am
> guessing that this gives me a numerical value for the future date & time)
>
> Title = ...."some stuff".... + "On " + DateTimeToStr(nextDateTime);
>
> Problem seems to be that the functions do not like referencing beyond
> the last bar. The displayed string is always just the date & time of the
> most recent bar.
>
> Can anyone help?
> TIA
>
>
> ___________________________________________________________
> To help you stay safe and secure online, we've developed the all new
Yahoo! Security Centre. http://uk.security.yahoo.com
>
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
>
> Yahoo! Groups Links
>
>
>
>
>
>