Skip to content

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

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. Unlike timeframe.period, this variable's value does not change when used in the expression argument of a request.*() function call.


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

pine
timeframe.change(string timeframe) → bool

Detects changes in the specified timeframe.

Parameters

NameTypeDefaultDescription
timeframestring

Returns: bool


from_seconds

pine
timeframe.from_seconds(int seconds) → 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

pine
timeframe.in_seconds(string timeframe = 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.

基于 MIT 许可证发布。