The closing price of the current bar; on a bar that is still forming, the latest traded price.
close is a series float: close[1] is the previous bar's close, close[2] the one before it, and so on. It is the default source for almost every indicator, so ta.sma(close, 20) and ta.rsi(close, 14) read this series.
On a bar that has finished, close never changes. On the live bar it moves with every tick, and your script runs again on each tick, so anything built on close can flip back and forth until the bar closes.
Type
series float
Remarks
- close[n] is na when n reaches back past the first bar of the chart.
- Test
barstate.isconfirmedbefore acting on a close that must not change, such as an alert or a signal you plan to trade.
Example
//@version=6
indicator("Close vs SMA", overlay = true)
avg = ta.sma(close, 20)
plot(close, "Close", color.gray)
plot(avg, "SMA 20", close > avg ? color.green : color.red, 2)
bgcolor(ta.crossover(close, avg) ? color.new(color.green, 85) : na)See also
Runs on Sidechair