ScriptingMarket data a script can readOrderflow: buying, selling and delta

Orderflow: buying, selling and delta

You want to know how a bar’s activity divided between buying and selling, and whether that balance is moving. Ten variables and one function answer that. No other orderflow name is available to a script.

All ten variables are integer series, read from the bar’s footprint data.

What each name measures

NameTypeWhat it gives you
orderflow.buyseries intBuy trades in the bar
orderflow.sellseries intSell trades in the bar
orderflow.tradesseries intAll trades in the bar
orderflow.buyvolumeseries intVolume bought in the bar
orderflow.sellvolumeseries intVolume sold in the bar
orderflow.deltaseries intThe bar’s delta at its close
orderflow.maxdeltaseries intThe highest delta reached inside the bar
orderflow.mindeltaseries intThe lowest delta reached inside the bar
orderflow.cothighseries intCommitment-of-traders high for the bar
orderflow.cotlowseries intCommitment-of-traders low for the bar

Counts are not volumes

orderflow.buy and orderflow.sell count trades. orderflow.buyvolume and orderflow.sellvolume measure the volume those trades moved. orderflow.trades is the bar’s overall trade count.

The two pairs are separate measurements, not two views of one figure. A bar can carry more buy trades than sell trades while more volume goes the other way. Pick the pair that answers your question, and do not treat one as a stand-in for the other.

Delta, and the extremes inside a bar

orderflow.delta is the bar’s delta as at its close. orderflow.maxdelta and orderflow.mindelta are the highest and the lowest delta the bar reached while it was forming.

Both extremes belong to that bar alone. They are not running highs and lows across the chart, so a new bar starts them afresh. A bar can therefore close near zero and still have swung a long way in each direction on the way there. If that swing is what you are after, read the extremes; the closing figure will not show it.

// The bar's delta at close.
indicator("Bar delta")
plot(orderflow.delta)

Commitment of traders

orderflow.cothigh and orderflow.cotlow are the commitment-of-traders high and low for the bar. They come from the same per-bar footprint summary as the delta figures.

That summary also holds a buy and a sell breakdown of each. Lipi does not expose those, so a script can read the high and the low only.

Bars with no footprint data

Not every bar carries footprint data. On a bar that carries none, every orderflow variable reads na — the counts, the volumes, the delta figures and the commitment-of-traders figures alike.

Write your script to handle na rather than assume a number. That behaviour is also what lets you test for the data instead of assuming it is there: an absent figure reads na, not zero, so a script can tell a missing bar from a bar that genuinely traded flat, and an instrument with no orderflow data from one that has it.

Cumulative delta

orderflow.cvd() → series int

orderflow.cvd() takes no arguments and returns an integer series. On each bar it adds that bar’s delta to a running total.

The total restarts from zero on the first bar of every session. What you plot is the accumulation within the current session, not a total that runs from the start of the chart. Read the result with the session boundaries in mind: the drop to zero at a boundary is the restart, not a turn in the market.

Where a bar’s delta is na, the running total carries forward unchanged rather than becoming na itself.

// Delta accumulated since the start of the session.
indicator("Cumulative delta")
plot(orderflow.cvd())
Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade