Hi, Any one test Ara code?
//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); --- In [email protected], "Ara Kaloustian" <a...@...> wrote: > > 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); >
