Skip to content
Algo Trade Analytics Docs

timeframe - Pine Script Variable

Flags and values describing the script’s active timeframe.

FieldTypeDescription
timeframe.isdailysimple boolReturns true if current resolution is a daily resolution, false otherwise.
timeframe.isdwmsimple boolReturns true if current resolution is a daily or weekly or monthly resolution, false otherwise.
timeframe.isintradaysimple boolReturns true if current resolution is an intraday (minutes or seconds) resolution, false otherwise.
timeframe.isminutessimple boolReturns true if current resolution is a minutes resolution, false otherwise.
timeframe.ismonthlysimple boolReturns true if current resolution is a monthly resolution, false otherwise.
timeframe.issecondssimple boolReturns true if current resolution is a seconds resolution, false otherwise.
timeframe.istickssimple boolReturns true if current resolution is a ticks resolution, false otherwise.
timeframe.isweeklysimple boolReturns true if current resolution is a weekly resolution, false otherwise.
timeframe.main_periodsimple stringA string representation of the script’s main timeframe. If the script is an indicator that specifies a timeframe value in its declaration statement, this variable holds that value. Otherwise, its value represents the chart’s timeframe. Unlike timeframe.period, this variable’s value does not change when used in the expression argument of a request.*() function call.
timeframe.multipliersimple intMultiplier of resolution, e.g. ‘60’ - 60, ‘D’ - 1, ‘5D’ - 5, ‘12M’ - 12.
timeframe.periodsimple stringA string representation of the script’s main timeframe or a requested timeframe, depending on how the script uses it. The variable’s value represents the timeframe of a requested dataset when used in the expression argument of a request.*() function call. Otherwise, its value represents the script’s main timeframe (timeframe.main_period), which equals either the timeframe argument of the indicator declaration statement or the chart’s timeframe.
  • Inside request.*() expressions, timeframe.period reflects the requested dataset. Use timeframe.main_period to access the script’s main timeframe consistently.
  • timeframe.period: To always access the script’s main timeframe, even within another context, use the timeframe.main_period variable.
//@version=6
indicator("Timeframe-aware length", overlay=false)
len = timeframe.isintraday ? 20 : 50
plot(ta.sma(close, len))