FuturaDevelopers

Market data

OHLCV, historical series, derived prices and time in NeuroScript.

A NeuroScript indicator runs candle by candle over the market data. On every candle, the variables below point to the value of that candle, and the script is re-evaluated from the start.

OHLCV

The five base series of the current candle, all series<float>:

VariableMeaning
openOpen
highHigh
lowLow
closeClose
volumeVolume
//@version=6
indicator("Candle body", overlay=false)
corpo = close - open
plot(corpo, "Body", color=corpo >= 0 ? color.green : color.red)

Historical series

Every series keeps the values of previous candles. Use [n] to look n candles back ([0] is the current candle, same as using no index):

anterior = close[1]          // close of the previous candle
variacao = close - close[1]  // change from the previous one
ha10 = close[10]             // close 10 candles back

On candles at the start of the chart, where there isn't enough history yet, the access returns na (missing value).

Derived prices

Common shortcuts, already computed on every candle (series<float>):

VariableFormula
hl2(high + low) / 2
hlc3(high + low + close) / 3 — typical price
ohlc4(open + high + low + close) / 4
hlcc4(high + low + close + close) / 4
// moving average over the typical price instead of the close
avg = ta.sma(hlc3, 20)

Time and bar index

VariableTypeMeaning
timeseries<int>Candle open timestamp (UNIX ms)
bar_indexseries<int>Index of the current candle (starts at 0)
last_bar_indexintIndex of the last candle on the chart
timenowintCurrent real time (UNIX ms)
// highlights the first 50 candles of the chart
inicio = bar_index < 50
plot(inicio ? high : na, "Start", color=color.orange)

Missing values (na)

na represents "no value" — it shows up in lookback beyond the available history or in calculations that aren't ready yet. Plotting na simply draws nothing on that candle, which is useful for conditional signals:

// only marks when it closes above the previous high
rompimento = close > high[1] ? high : na
plot(rompimento, "Breakout", color=color.green, style="circles")

Timeframe and symbol

Information about the chart's timeframe and the asset lives in the timeframe.* and syminfo.* namespaces. The details go into the reference along with the other namespaces.

Next

On this page