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

Re: [amibroker] Time left in bar



PureBytes Links

Trading Reference Links

Jeff,  Thanks
----- Original Message -----
From: Jeff
Sent: Thursday, September 22, 2005 4:33 PM
Subject: RE: [amibroker] Time left in bar

Hi Ara.   Awhile back, Alex Dolaptchiev posted some code. 
Alex, if your reading this, thanks!!!!
 
This is my modified version, setting is Start Time Of
Interval.    Works good, I just add the function in the
my title statements.
 
function CountDownTimer( )
   {
   
//  CountDown Timer

   thisbar =
TimeNum
();
   nextbar = thisbar+(
Interval()/60*100
);
   systime =
Now(4); //pt time zone

   systime =
IIf(systime>=240000,systime-240000
,systime);
   anewbar = nextbar-systime-
40
;
   anewbar =
IIf(anewbar<0,0
,anewbar );
   nnewbar =
LastValue
(anewbar);
   
   
if (nnewbar > 20) timercode = EncodeColor(colorBlue
);
   
else timercode = EncodeColor(colorRed
);

   anewbar=
NumToStr(anewbar,1,False
);
   length=
StrLen
(anewbar);

   
if (length== 1) timercode=timercode + "00:0"
+ anewbar;
   
else if (length== 2) timercode=timercode +  "00:"
+ anewbar;
   
else if (length== 3) timercode= timercode +  "0"+ StrLeft( anewbar, 1) + ":" + StrRight( anewbar, 2
) ;
   
else if (length== 4) timercode= timercode +  StrLeft( anewbar, 2) + ":" + StrRight( anewbar, 2
) ;
   
else timercode=timercode +  "00:00"
;

   timercode=
EncodeColor(colorBlack) + "  Timer: "
+ timercode;
   
return
timercode;
   }

--jeff
 
 -----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]On Behalf Of Ara Kaloustian
Sent: Thursday, September 22, 2005 3:02 PM
To: AB-Main
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);



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