/* GetTimeFrame
returns the number of seconds in the selected Timeframe:
60 = 1 minute
300 = 5 minutes
3600 = 1 hour
14400 = 4 hours
86400 = 1 day (24 hours)
604800 = 1 week (7 days)
2592000 = 1 month (30 days)
31536000 = 1 year (365 days)
-1 = default TF (or non time based TF)
this indicator returns two values (commented out as it plots text)
TF = 0 seconds
TF = 1 minutes
TF = 2 hours
TF = 3 days
TF = 4 weeks
TF = 5 months
TF = 6 years
N = number of units
*/
DEFPARAM DrawOnlastBarOnly = true
ShiftText = 1
Rge = high + averagetruerange[2](close) / 0.4 / ShiftText / 1
//
x = GetTimeFrame
IF (x MOD 60) <> 0 THEN
TF = 0 //TF = seconds
N = x //N = number of seconds
DRAWTEXT("#N# Sec", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
ELSE
IF x >= 31536000 THEN
TF = 6 //TF = years
N = floor(x / 31536000,0) //N = number of years
DRAWTEXT("#N# Yrs", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
ELSIF x >= 2592000 THEN
TF = 5 //TF = months
N = floor(x / 2592000,0) //N = number of months
DRAWTEXT("#N# Mth", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
ELSIF x >= 604800 THEN
TF = 4 //TF = weeks
N = floor(x / 604800,0) //N = number of weeks
DRAWTEXT("#N# wks", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
ELSIF x >= 86400 THEN
TF = 3 //TF = days
N = floor(x / 86400,0) //N = number of days
DRAWTEXT("#N# Day", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
ELSIF x >= 3600 THEN
TF = 2 //TF = hours
N = floor(x / 3600,0) //N = number of hours
DRAWTEXT("#N# hrs", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
ELSE
TF = 1 //TF = minutes
N = floor(x / 60,0) //N = number of minutes
DRAWTEXT("#N# Min", BarIndex,Rge,SansSerif,Standard,18) COLOURED(20,150,150,255)
ENDIF
ENDIF
RETURN// TF AS "TF",N AS "Units"