ScriptingLanguageOrderflow Varialbles

๐Ÿ“˜ Orderflow Variables in Lipi Script

Orderflow analysis provides traders with a deeper understanding of market dynamics by examining who is in control โ€” buyers or sellers โ€” and how aggressively they are acting. Instead of relying solely on price and volume, orderflow reveals the intensity and direction of trading pressure within each candle.

Lipi Script offers a robust set of orderflow. variables that enable you to access and visualize detailed trade-level information, including the number of trades, aggressor direction, volume imbalance, and delta strength. These variables are optimized for use on footprint on the GoCharting platform, where orderflow data is available.

These tools are essential for identifying concepts like absorption, exhaustion, divergence, and imbalance, allowing for highly informed trading decisions.


๐Ÿ”ง Syntax

All orderflow variables follow this structure:

orderflow.<variable_name>

Example:

plot(orderflow.delta)

๐Ÿ“‹ Available Orderflow Variables

VariableDescription
orderflow.tradesTotal number of trades in the current bar.
orderflow.buyNumber of aggressive buy trades.
orderflow.sellNumber of aggressive sell trades.
orderflow.buyvolumeTotal volume of all buy trades in the bar.
orderflow.sellvolumeTotal volume of all sell trades in the bar.
orderflow.deltaBuy volume minus sell volume.
orderflow.maxdeltaPeak positive delta within the bar (strongest point of buying pressure).
orderflow.mindeltaPeak negative delta within the bar (strongest point of selling pressure).
orderflow.cothighCOTHigh โ€” cumulative delta tracked from the point where price makes or retests a high.
orderflow.cotlowCOTLow โ€” cumulative delta tracked from the point where price makes or retests a low.

๐Ÿงช Basic Usage Examples

๐Ÿ“Š Plot Delta

indicator("Delta Plot", overlay=false)
 
barColor = orderflow.delta >= 0 ? color.green : color.red
 
plot(orderflow.delta, color=barColor, title="Delta", style=plotStyle.bar)

grid

๐Ÿ“Š Plot Cumulative Volume Delta(CVD)

indicator("Cumulative Volume Delta (9:15 to 15:30)", overlay=false)
 
// Use your delta input
delta = orderflow.delta
 
// Define session time range (Indian stock market hours)
inSession = (hour == 9 and minute >= 15) or (hour > 9 and (hour < 15 or (hour == 15 and minute <= 30)))
 
// Identify the session start
isSessionStart = (hour == 9 and minute == 15)
 
// Persistent cumulative delta
static int cumDelta = na
 
if isSessionStart {
    cumDelta := delta
} else if inSession {
    cumDelta := cumDelta + delta
} else {
    cumDelta := na 
}
plot(cumDelta, color=color.teal, title="Cumulative Orderflow Delta")
// Add zero horizontal line
hline(0, title="Zero Line", color=color.red, style=hlineStyle.dotted)

grid

๐Ÿ“Š Plot Buy and Sell Volume

indicator("Buy/Sell Volume", overlay=false)
 
plot(orderflow.buyvolume, color=color.green, title="Buy Volume")
plot(orderflow.sellvolume, color=color.red, title="Sell Volume")

grid

๐Ÿ” Visualize Number of Buy and Sell Trades

indicator("Buy/Sell Trades", overlay=false)
 
plot(orderflow.buy, color=color.green, title="Buy Trades")
plot(orderflow.sell, color=color.red, title="Sell Trades")

grid

๐Ÿ“ˆ Advanced Concepts

๐ŸŸข Highlight Strong Buy Pressure with Max Delta

indicator("Strong Buy Pressure", overlay=true)
 
strongBuy = orderflow.maxdelta > 10000
bgcolor(strongBuy ? color.new(color.green, 0.2) : na)

grid

๐Ÿ”ด Highlight Strong Sell Pressure with Min Delta

indicator("Strong Sell Pressure", overlay=true)

strongSell = orderflow.mindelta < -100000
bgcolor(strongSell ? color.new(color.red, 0.2) : na)

grid

๐Ÿ”ต Plot COTHigh

orderflow.cothigh tracks cumulative delta from the moment price hits or revisits a high.

indicator("COTHigh Example", overlay=false)
 
plot(orderflow.cothigh, title="COTHigh", color=color.red)

grid

๐ŸŸ  Plot COTLow

orderflow.cotlow tracks cumulative delta from the moment price hits or revisits a low.

indicator("COTLow Example", overlay=false)
 
plot(orderflow.cotlow, title="COTLow", color=color.green)

grid

๐Ÿง  Tips and Best Practices

  • Use delta-based metrics (delta, maxdelta, mindelta) to gauge real-time buying or selling pressure beyond what price alone can show.
  • Combining orderflow with price action can help detect exhaustion, absorption, or hidden divergences.
  • buyvolume and sellvolume provide a more detailed view of aggressor activity compared to traditional volume.
  • Sharp increases in trades or buy/sell counts can indicate momentum ignition or event-driven spikes.
  • Orderflow imbalances are most meaningful during breakout attempts or near support/resistance zones.
  • Large differences between maxdelta and mindelta within the same candle may reflect volatile or trapped conditions.