The timeframe of the chart itself as a string, unchanged inside a request.security call that uses another timeframe.
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.periodinto a variable before therequest.security()call. - On Sidechair: the same string as
timeframe.period, for the chart's timeframe.
Example
//@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