timeframe
Properties
isdaily
Type: simple bool
Returns true if current resolution is a daily resolution, false otherwise.
isdwm
Type: simple bool
Returns true if current resolution is a daily or weekly or monthly resolution, false otherwise.
isintraday
Type: simple bool
Returns true if current resolution is an intraday (minutes or seconds) resolution, false otherwise.
isminutes
Type: simple bool
Returns true if current resolution is a minutes resolution, false otherwise.
ismonthly
Type: simple bool
Returns true if current resolution is a monthly resolution, false otherwise.
isseconds
Type: simple bool
Returns true if current resolution is a seconds resolution, false otherwise.
isticks
Type: simple bool
Returns true if current resolution is a ticks resolution, false otherwise.
isweekly
Type: simple bool
Returns true if current resolution is a weekly resolution, false otherwise.
main_period
Type: simple string
Returns the base timeframe chosen for the script itself.
Inside request.*() expressions this value still points to the outer script's timeframe rather than the temporary request timeframe.
multiplier
Type: simple int
Multiplier of resolution, e.g. '60' - 60, 'D' - 1, '5D' - 5, '12M' - 12.
Type: simple int
Multiplier of resolution, e.g. '60' - 60, 'D' - 1, '5D' - 5, '12M' - 12.
period
Type: simple string
A 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. The string's format is "<quantity>[<unit>]", where <unit> is "T" for ticks, "S" for seconds, "D" for days, "W" for weeks, and "M" for months, but is absent for minutes. No <unit> exists for hours: hourly timeframes are expressed in minutes. The variable's value is: "10S" for 10 seconds, "30" for 30 minutes, "240" for four hours, "1D" for one day, "2W" for two weeks, and "3M" for one quarter.
Type: simple string
A string representation of the script's main timeframe or a requested timeframe.
Functions
change
timeframe.change(timeframe: string): boolDetects changes in the specified timeframe.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
timeframe | string |
Returns: bool
from_seconds
timeframe.from_seconds(seconds: int): stringConverts seconds into a timeframe string.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
seconds | int | The number of seconds to convert. |
Returns: string — A timeframe string (e.g., 3600 returns "60", 86400 returns "D").
in_seconds
timeframe.in_seconds(timeframe: string = timeframe.period): simple intConverts a timeframe string into seconds.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
timeframe | string | timeframe.period | The timeframe string to convert. Defaults to the chart's timeframe. |
Returns: simple int — The number of seconds in one bar of the given timeframe. For example, "D" returns 86400, "60" returns 3600.