check this out to see if it meets your needs...just wrote this seeing this request. First bar will not work on the days that do not start at normal daily start time or prev trading day ends at a diff time than usual trading close time, like muhurat trading, or test trading on Saturdays, etc
_SECTION_BEGIN("TimeRemaining");
// Author: Pratap Balakrishnan
// email id: [email protected]
//
/*
Shows remaining time of the Last Bar
uses the time stamp of the last bar and previous bar to calculate so it should work independent of TF.
So for the 1st bar of the day adjustment is required as the prev bar is of the previous day.
It is also expected to accomodate for multiple holidays in between.
This adjustment factor is the difference between today's mkt start time and yday mkt end time in minutes.
This is adjustable in Parameters for differnt markets. Default is as per NSE equity mkt timings.
*/
daych = Day() != Ref(Day(), -1) ;
dt = DateTime() ;
Lastbardone = DateTimeDiff(dt[BarCount-1], dt[BarCount-2]) ;
Lastbarremain = Interval() - Lastbardone ;
fontsize = Param("Font Size", 14, 3, 100, 1) ;
GfxSelectFont( "Tahoma", fontsize , 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( ParamColor("Text Color", colorBlack) );
pxHeight = Status( "pxchartheight" ) ;
pxWidth = Status( "pxchartwidth");
dt_flag = 16 /*wordbreak*/;
textht = 200;
x = pxWidth - Param("from right edge", 150, 0, 1000, 1) ;
y = Param("From Top", 50, 0, 1000, 1) ;
firstbaradjust = Param("First Bar Adjust", 1065, 1, 100000, 1) ;
Lastbarremain =IIf(Daych, (Lastbarremain%inDaily)+(firstbaradjust*in1Minute),Lastbarremain) ;
Lastbarremain_min = int(Lastbarremain / in1Minute) ;
Lastbarremain_sec = Lastbarremain % in1Minute ;
GfxDrawText(NumToStr(Lastbarremain_min, 1.0)+" min "+NumToStr(Lastbarremain_sec, 1.0)+" sec", x,y, x+130, y+textht , dt_flag) ;
_SECTION_END();
_SECTION_BEGIN("TimeRemaining");
// Author: Pratap Balakrishnan
// email id: [email protected]
//
/*
Shows remaining time of the Last Bar
uses the time stamp of the last bar and previous bar to calculate so it should work independent of TF.
So for the 1st bar of the day adjustment is required as the prev bar is of the previous day.
It is also expected to accomodate for multiple holidays in between.
This adjustment factor is the difference between today's mkt start time and yday mkt end time in minutes.
This is adjustable in Parameters for differnt markets. Default is as per NSE equity mkt timings.
*/
daych = Day() != Ref(Day(), -1) ;
dt = DateTime() ;
Lastbardone = DateTimeDiff(dt[BarCount-1], dt[BarCount-2]) ;
Lastbarremain = Interval() - Lastbardone ;
fontsize = Param("Font Size", 14, 3, 100, 1) ;
GfxSelectFont( "Tahoma", fontsize , 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( ParamColor("Text Color", colorBlack) );
pxHeight = Status( "pxchartheight" ) ;
pxWidth = Status( "pxchartwidth");
dt_flag = 16 /*wordbreak*/;
textht = 200;
x = pxWidth - Param("from right edge", 150, 0, 1000, 1) ;
y = Param("From Top", 50, 0, 1000, 1) ;
firstbaradjust = Param("First Bar Adjust", 1065, 1, 100000, 1) ;
Lastbarremain =IIf(Daych, (Lastbarremain%inDaily)+(firstbaradjust*in1Minute),Lastbarremain) ;
Lastbarremain_min = int(Lastbarremain / in1Minute) ;
Lastbarremain_sec = Lastbarremain % in1Minute ;
GfxDrawText(NumToStr(Lastbarremain_min, 1.0)+" min "+NumToStr(Lastbarremain_sec, 1.0)+" sec", x,y, x+130, y+textht , dt_flag) ;
_SECTION_END();
Last edited: