Skip to content

timeframe

Properties

is_daily

Type: simple bool

Returns true if current resolution is a daily resolution, false otherwise.


is_dwm

Type: simple bool

Returns true if current resolution is a daily or weekly or monthly resolution, false otherwise.


is_intraday

Type: simple bool

Returns true if current resolution is an intraday (minutes or seconds) resolution, false otherwise.


is_minutes

Type: simple bool

Returns true if current resolution is a minutes resolution, false otherwise.


is_monthly

Type: simple bool

Returns true if current resolution is a monthly resolution, false otherwise.


is_seconds

Type: simple bool

Returns true if current resolution is a seconds resolution, false otherwise.


is_ticks

Type: simple bool

Returns true if current resolution is a ticks resolution, false otherwise.


is_weekly

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

navi
timeframe.change(timeframe: String): bool

Detects changes in the specified timeframe.

Parameters

NameTypeDefaultDescription
timeframeString

Returns: bool


from_seconds

navi
timeframe.from_seconds(seconds: int): String

Converts seconds into a timeframe String.

Parameters

NameTypeDefaultDescription
secondsintThe number of seconds to convert.

Returns: String — A timeframe String (e.g., 3600 returns "60", 86400 returns "D").


in_seconds

navi
timeframe.in_seconds(timeframe: String = timeframe.period): simple int

Converts a timeframe String into seconds.

Parameters

NameTypeDefaultDescription
timeframeStringtimeframe.periodThe 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.