Sidechair

timeframe.main_period

Browse the reference

The timeframe of the chart itself as a string, unchanged inside a request.security call that uses another timeframe.

Try it in the editor

timeframe.main_period holds the timeframe the chart displays, such as "5" or "60". It matches timeframe.period everywhere except in code that runs inside a request.security() call, where timeframe.period is the requested timeframe and timeframe.main_period is still the chart's.

Use it inside a function that is called both on the chart and through request.security(), when you need to know what the chart is showing. It is a simple string.

Type

simple string

Remarks

  • To keep the chart's timeframe in older code, read timeframe.period into a variable before the request.security() call.
  • On Sidechair: the same string as timeframe.period, for the chart's timeframe.

Example

Pine ScriptChart timeframe labelOpen in editor
//@version=6
indicator("Main period", overlay = true)
plot(close, "Close", color.gray)
if barstate.islast
    label.new(bar_index, high, "Chart: " + timeframe.main_period, style = label.style_label_down)

See also

Runs on Sidechair