Skip to content

Order flow

Delta, cumulative delta and relative volume

Order-flow indicators computed from aggressor volumes rather than guessed from the close.

Delta, cumulative delta and relative volume@ortex-charts/financial
Loading delta, cumulative delta and relative volume…
Order-flow indicators computed from aggressor volumes rather than guessed from the close.

What this example is for

Delta is the volume that lifted the offer minus the volume that hit the bid; cumulative delta is its running total, and relative volume compares today with the same minute on a normal day. All three come from aggressor volumes when the feed supplies them, and say so in the tooltip when they had to be estimated. Reach for them when order flow is the argument your product makes.

delta-cvd.ts
import { createFinancialChart, footprintFromTicks, mergeFootprint } from "@ortex-charts/financial";
import { SAMPLE_LOGO } from "@/lib/constants";
import { parseResolution, ticksToBars, type Bar, type Tick } from "@ortex-charts/math";

const RESOLUTION = parseResolution("15");
const bars = ticksToBars(prints, RESOLUTION, TIME_ZONE);
// Derived for this page: the sample feed reports no aggressor side, so the
// tick rule classifies each print. A feed that reports it sets `side` and
// every number below becomes exact rather than inferred.
const flow = footprintFromTicks(prints, RESOLUTION, 0.05, TIME_ZONE);

const chart = createFinancialChart(box, {
    legend: { logo: SAMPLE_LOGO }, // the company mark beside the symbol in the legend
    theme,
    timeZone: TIME_ZONE,
    resolution: "15",
    // `mergeFootprint` writes buyVolume and sellVolume onto every bar. The
    // indicators below read those columns; without them they fall back to
    // the estimate and say so.
    data: mergeFootprint(bars, flow),
    volume: false,
    seriesOptions: { priceFormat: { type: "price", precision: 2, minMove: 0.01 } },
});

const delta = chart.addIndicator("delta", { method: "auto" }, { paneHeightRatio: 0.22 });
const cvd = chart.addIndicator("cvd", { method: "auto" }, { paneHeightRatio: 0.22 });
chart.addIndicator("rvol", { length: 30 }, { paneHeightRatio: 0.22 });

chart.chart.subscribeCrosshairMove((e) => {
    if (e.index === null) return;
    const parts: string[] = [];
    for (const [id, value] of e.seriesValues) {
        const series = chart.chart.getSeries(id);
        if (!series || "close" in value || !Number.isFinite(value.value)) continue;
        parts.push(`${series.options.title} ${Math.round(value.value).toLocaleString()}`);
    }
    status(parts.join("   "));
});