Status (lastbartimeleft) - show negative value

Hi all,
im trying to get "seconds to go" number.
i'm working with intraday M1 data & also compress it into Daily.
those data are NOT mixed intraday & EOD, and i can get around 6 months of daily chart.

By using status (lastbartimeleft), it works perfectly in all intraday chart.
but when it used in Daily chart, the number shows negative value.

please help me, is there any workaround for this, or maybe i miss some settings?
note: timeshift already set, so it's already align between local and exchange time.

thank you.

EOD bars are special, they have special virtual time stamp of "end-of-day" i.e. AFTER all bars of given day and AFTER all times of given day (AFTER 23:59:59.999999).
Status("lastbartimeleft") is designed to be used with RT database (intraday).

Thanks Tomasz for clarification about Status().

Uhm but i still need the seconds number to use in D, W, and even Monthly chart.
Because my afl is calculating, to "predict" the outlook of last running bar, before completion.

If you say that status only apply to intraday, can you give me some hints how to do it best for longer than intraday (D,W,M)

My thoughts:
I am now thinking of finding the timestamp of last prevoius bar (c,-1), and then calculate "seconds-to-go" from a maximum elapse of 86400 seconds from last previous bar (i.e for D chart).
But is this the best approach? I am trying not way too far from efficient afl approach.

Hopefully you can give me some hints about my problem.


as non programmer doing programming,
sometimes... the solution is actually just around the corner :man_facepalming:
After around 2 months, while alternately finishing my other part of the code, i finally managed this part.

I dont know if this the best (efficient) approach and applicable for others with other database setting, but at least this is working for my needs

i shared it here, thinking this might be useful also for someone else in this forum whose trying to get "seconds to go" at higher than EOD/Daily timeframe (D1, W1, Monthly, .....) for whatever reasons :grin:



if(Interval(0) != 432001 OR Interval(0) != 86400 OR Interval(0) != 14400 ) {
	SecsToGo = Status( "lastbartimeleft" );
	STGText = "STG: " + NumToStr( SecsToGo, 1.0, False ) + " seconds";
// i thought at first this also impacted H4 timeframe 
//but seems like no problem, so 14400 can be commented & ignored.

if(Interval(0) == 14400) {
	SecsToGo = Status( "lastbartimeleft" );
	STGText = "STG: " + NumToStr( SecsToGo, 1.0, False ) + " seconds";
if(Interval(0) == 86400){	
// to be honest i dont know exactly why i would need to add back 86400, 
//but this works in my case (my database timeshift: 5, to match local time)
	SecsToGo = Status( "lastbartimeleft" ) + 86400; 
	STGText = "STG: " + NumToStr( SecsToGo, 1.0, False ) + " seconds";

if(Interval(0) == 432001) {
//same thing with Weekly, but this time i need to substract with 86400 :D. dont ask me why
	SecsToGo = Status( "lastbartimeleft" ) - 86400;
	STGText = "STG: " + NumToStr( SecsToGo, 1.0, False ) + " seconds";
1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.