----- Original Message -----
Sent: Thursday, September 22, 2005 3:21
PM
Subject: Re: [amibroker] Time left in
bar
Ara,
This actually depends on settings and data
source you are using.
If time-compressed bars are
considered,
when you want to use such
approach you need to go to
Tools->Preferences->Intraday
and set
"END time of interval".
Otherwise Now() may be greater than
timenum.
If base time interval is considered - this
depends on data source.
Most real time data source timestamp quotes
using exchange time
which may be different than your computer's
clock.
Some data sources do not timestamp at all
(DDE/IB) and then
computer clock is used, and then usually
TimeNum represents
the time of last trade (local
clock)
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
Sent: Friday, September 23, 2005
12:01 AM
Subject: [amibroker] Time left in
bar
Recently I posted my "imperfect" code...
someone else posted code for same function... both seem to have similar
problems.
I reviewed my code and reduced it to
basics.
Design Concept:
TimeLeftinBar = TimeNum() - Now(4);
If time numbet() is set to display the end
of bar time, then Now(4) will always be less the TimeNum() by an amount
equal to time left.
Problem: Time
returned by Now(4) is sometimes greater the TimeNum(), sometime by a
significant amount. It seems that new bars are not created at the
transition of minute bars.
Would someone test the code below to verify
my results. Should be tested when RT data is flowing in. All data
will appear in title.
Thanks
Ara
//File: Time Left in Bar
PlotOHLC
(Open,High,Low,Close,"",colorBlack,styleCandle);
BarTime1 = (LastValue(TimeNum() - Now(4)));
_N
(TimeBase = Interval(2));
_N
(StrBarTime = NumToStr(BarTime1,1.0,False));
BT_Length = StrLen(StrBarTime);
//Format time left for display
_N
(TimeLeft = WriteIf(BT_Length==1,"0:0"+StrBarTime,WriteIf(BT_Length==2,"0:"+StrBarTime,
WriteIf(BT_Length==3,StrLeft(StrBarTime,1)+":"+StrRight(StrBarTime,2),
StrLeft(StrBarTime,2)+":"+StrRight(StrBarTime,2)))));
_N
(Title = "Time Left Test -
Interval: " + TimeBase + " TimeNum: " +
WriteVal(TimeNum(),1.0)
+ " Now: " + Now(4) + " TimeLeft: " +
TimeLeft);