Price and volume
Every bar carries five values you can read by name. Four averaged prices are supplied alongside them, and the bar itself has an index.
The bar’s values
open, high, low, close and volume are float series. Each holds the value for the bar your script is being evaluated on, and each moves on as the script advances through the chart.
| Name | Type | Holds |
|---|---|---|
open | series float | The bar’s open |
high | series float | The bar’s high |
low | series float | The bar’s low |
close | series float | The bar’s close |
volume | series float | The bar’s volume |
Averaged prices
Four further names average values from the same bar. They exist so that you need not compute the average yourself. Each is a float series, like the values it averages, so you can use one anywhere a price is expected.
| Name | Type | Averages |
|---|---|---|
hl2 | series float | The high and the low |
hlc3 | series float | The high, the low and the close |
hlcc4 | series float | The high, the low and the close counted twice |
ohlc4 | series float | The open, the high, the low and the close |
The bar index
bar_index is an int series rather than a float. Like a price, it changes from bar to bar.
| Name | Type | Holds |
|---|---|---|
bar_index | series int | The index of the bar |
A script that plots two of them
indicator("Close and typical price")
plot(close)
plot(hlc3)Both plot calls sit at the top level of the script. Chart-output functions have to be called there: a call placed inside a branch, inside a loop or inside a function of your own is rejected.
Reading an earlier bar
To read one of these values from an earlier bar, put an index in square brackets after the name. The index is itself an expression, so it need not be a literal.
close[1]The rules for reading past bars are set out in Referencing past bars.