|AlertHHMMSS||String||"00:02:00"||The time remaining in the bar in HH:MM:SS fomat, for an alert. If the time remaining is less than this value, an alert will be triggered.|
|TextColorString||String||"Green"||String that represents the desired color of the text (in Charting). See the elsystem.drawing.KnownColor class for a list of available colors.|
|TextFontName||String||"Arial"||Name of the font that is to be used for text objects (in Charting).|
|TextFontSize||Numeric||9||Point size of the desired font for text objects (in Charting).|
|TextLabelOffsetTicks||Numeric||7||Number of ticks that the text label will be offset above the High or below the Low (in Charting).|
|NumSecondsErrorAllowed||Numeric||10||The maximum allowed number of seconds difference between computer clock and bar time stamp.|
This indicator works in Charting and RadarScreen on intraday and second bars only. If this indicator is applied to a bar type that is not intraday or second bars in Charting, the text will be set to "N/A" and a dialog displayed if the prior bar type on the chart was a supported bar type. If this indicator is applied to a bar type that is not intraday or second bars in RadarScreen, a runtime error is thrown.
The basic function of this indicator is to provide the user with the time remaining in a time-based bar. It is plotted in HH:MM:SS format, unless there is less than 1 hour remaining in the bar, in which case, it plots MM:SS. In RadarScreen, a plot is used and for Charting, a TextLabel object is used. For Charting, inputs allow for controlling the text color of the text label, the font of the text label, the font size of the text label, and the number of ticks to offset the text label from the High or Low. The positioning of the chart text label is designed to keep the text label visible. The position is set to the bar high or low (plus or minus the offset ticks) based on price location in the chart. As price moves toward the top of the chart, the text label is positioned to the bar low and as price moves toward the bottom of the chart, the text label is positioned to the bar high.
The code uses a Timer object to update the remaining time every second (and check for alerts) to allow for timely updates even with symbols that are not heavily traded. If applied after hours and there are no currently forming bars, "00:00" is displayed remaining time since the bar is closed and there is no remaining time in that bar.
In real-time, a check is made to ensure the computer time clock and the bar date/time stamps are the “same” within the number of seconds specified in the ‘NumSecondsErrorAllowed’ input. If the difference is larger than the input value, a warning dialog is displayed (Charting) or an exception is thrown (RadarScreen). If the calculated time remaining in the bar is greater than the bar interval (due to PC time difference as compared to the bar time stamp), the displayed time remaining will be the bar interval until the calculated time is less than or equal to the bar interval.
For a chart that is set to Exchange, this code uses a SymbolAttributesProvider to obtain the time delta between the user's local PC time and the BarDateTime to allow for accurate calculations (the code uses the BarDateTime and the current computer time to calculate the remaining time in the bar).
Alerts are code to alert the user if the time remaining in the bar is less than the time entered into the 'AlertHHMMSS' input. If there is an error in parsing the 'AlertHHMMSS' inputs string when the code first runs, a runtime error is thrown.
Plots the time remaining in the bar.