Sidechair

timeframe.period

Browse the reference

The chart's timeframe as a string, such as "5" for five minutes or "60" for one hour.

Try it in the editor

timeframe.period is the resolution the script runs on, written the way Pine writes timeframes. Minute charts use the number of minutes ("1", "5", "60", "240"), second charts end in S ("30S"), and daily, weekly and monthly charts end in D, W or M. A v6 script reads "1D", "1W" and "1M" where a v5 script reads "D", "W" and "M".

Pass it to request.security() and timeframe.in_seconds() to refer to the chart's own timeframe, or build a string for another one with timeframe.from_seconds(). Because the string is the same on every bar, timeframe.period is a simple string.

Type

simple string

Remarks

  • When a script runs inside a request.security() call, timeframe.period is the timeframe of that call. timeframe.main_period always holds the chart's timeframe.
  • Do not compare it with a typed string to test for daily bars: use timeframe.isdaily or timeframe.in_seconds(), which do not depend on how the string is spelled.
  • On Sidechair: the string follows the chart: "5" on a five-minute chart, "30S" on a thirty-second one, and "1D", "1W" or "1M" style on daily and above in a v6 script ("D" and "W" in v5).

Examples

Pine ScriptShow the chart's timeframeOpen in editor
//@version=6
indicator("Timeframe label", overlay = true)
plot(close, "Close", color.gray)
if barstate.islast
    label.new(bar_index, high, syminfo.ticker + " on " + timeframe.period, style = label.style_label_down)
Pine ScriptTest for daily bars without a stringOpen in editor
//@version=6
indicator("Daily check", overlay = true)
bgcolor(timeframe.isdaily ? color.new(color.blue, 90) : na)
plot(timeframe.in_seconds(), "Seconds per bar", display = display.data_window)

See also

Runs on Sidechair