Skip to content
Nexus Prop LLC

NexuScript 1.5

Order flow

Volume at each price inside a bar, and the order book.

footprint

functionNexuScript 1.0

The volume traded at each price inside the current bar, split into buying and selling.

Syntax

footprint() -> (levels = Array{(price = Number, buy = Number, sell = Number)}, buy = Number, sell = Number, delta = Number, known = Bool)

Returns

(levels = Array{(price = Number, buy = Number, sell = Number)}, buy = Number, sell = Number, delta = Number, known = Bool) A tuple: levels is an array of (price, buy, sell), one per price, from the highest price down; buy and sell are the bar's total buying and selling volume; delta is buy - sell; known says whether the bar has any levels.

Details

The first time a script reads footprint(), the chart loads footprints and runs the script again, so the first run may see none. Check known before you trust the numbers.

Units and time zones

Prices in the symbol's quote currency; volume in contracts or units, as the chart shows it.

Missing values

It never gives missing. When the bar has no levels (the feed has no footprint for it, it has not loaded yet, or nothing traded) levels is empty, buy, sell and delta are 0, and known is false.

Live and historical bars

Closed bars read their stored footprint. The newest bar reads the footprint as it builds, so its numbers grow until the bar closes.

Examples

let fp = footprint()
plot("Delta", fp.known ? fp.delta : missing, style = "columns", color = fp.delta >= 0 ? color.green : color.red)
let fp = footprint()
let busiest = 0
for lvl in fp.levels
    busiest = max(busiest, lvl.buy + lvl.sell)
end
plot("Busiest price volume", fp.known ? busiest : missing)

See also

bookvolumetuplefor

book

valueNexuScript 1.0

The order book: the best bids and asks waiting right now.

Syntax

book::(bids = Array{(price = Number, size = Number)}, asks = Array{(price = Number, size = Number)}, spread = Number, last = Number)

Returns

(bids = Array{(price = Number, size = Number)}, asks = Array{(price = Number, size = Number)}, spread = Number, last = Number) A tuple: bids and asks are arrays of (price, size), best price first, at most 20 per side; spread is the best ask minus the best bid; last is the last traded price.

Details

Read it as book, with no brackets. The first time a script reads it, the chart asks for market depth.

Units and time zones

Prices in the symbol's quote currency; sizes in contracts or units.

Missing values

spread and last are missing when they are not known; spread needs at least one bid and one ask. With no depth, bids and asks are empty.

Live and historical bars

It is a snapshot taken just before the script runs, the same on every bar of that run. It only means something on the newest bar, so check bar.last before you use it. Older bars do not have their own book.

Examples

let depth = book
plot("Spread", bar.last ? depth.spread : missing)
let depth = book
if bar.last && length(depth.bids) > 0
    let best = first(depth.bids)
    marker("Best bid", price = best.price)
end

See also

footprintbar.lastbar.realtimetuple