Candles

API Reference

1. bar_index

DescriptionType

Current bar index. Numbering is zero-based, index of the first bar is 0.

series int

Example:

pinescriptCopy code//@version=5
indicator("bar_index")
plot(bar_index)
plot(bar_index > 5000 ? close : 0)

Remarks: Note that bar_index has replaced n variable in version 4. Note that bar indexing starts from 0 on the first historical bar. Please note that using this variable/function can cause indicator repainting.

2. close

DescriptionType

Close price of the current bar when it has closed, or last traded price of a yet incomplete, realtime bar.

series float

Remarks: Previous values may be accessed with square brackets operator [], e.g. close[1], close[2].

See Also: open, high, low, volume, time, hl2, hlc3, hlcc4, ohlc4

3. open

DescriptionType

Current open price.

series float

Remarks: Previous values may be accessed with square brackets operator [], e.g. open[1], open[2].

See Also: high, low, close, volume, time, hl2, hlc3, hlcc4, ohlc4

4. high

DescriptionType

Current high price.

series float

Remarks: Previous values may be accessed with square brackets operator [], e.g. high[1], high[2].

See Also: open, low, close, volume, time, hl2, hlc3, hlcc4, ohlc4

5. low

DescriptionType

Current low price.

series float

Remarks: Previous values may be accessed with square brackets operator [], e.g. low[1], low[2].

See Also: open, high, close, volume, time, hl2, hlc3, hlcc4, ohlc4 6. volume

DescriptionType

Current bar volume.

series float

Remarks: Previous values may be accessed with square brackets operator [], e.g. volume[1], volume[2].

See Also: open, high, low, close, time, hl2, hlc3, hlcc4, ohlc4

7. time

DescriptionType

Current bar time in UNIX format. It is the number of milliseconds that have elapsed since 00:00:00 UTC, 1 January 1970.

series int

Remarks: Note that this variable returns the timestamp based on the time of the bar's open. Because of that, for overnight sessions (e.g. EURUSD, where Monday session starts on Sunday, 17:00) this variable can return time before the specified date of the trading day. For example, on EURUSD, dayofmonth(time) can be lower by 1 than the date of the trading day, because the bar for the current day actually opens one day prior.

8. hl2

DescriptionType

Is a shortcut for (high + low)/2

series float

See Also: open, high, low, close, volume, time, hlc3, hlcc4, ohlc4

9. hlc3

DescriptionType

Is a shortcut for (high + low + close)/3

series float

See Also: open, high, low, close, volume, time, hl2, hlcc4, ohlc4

10. hlcc4

DescriptionType

Is a shortcut for (high + low + close + close)/4

series float

See Also: open, high, low, close, volume, time, hl2, hlc3, ohlc4

11. ohlc4

DescriptionType

Is a shortcut for (open + high + low + close)/4

series float

See Also: open, high, low, close, volume, time, hl2, hlc3, hlcc4

Last updated