TradingView price and volume calculations

Demand Index indicator: identify the formula before comparing values

The Sibbet Demand Index indicator combines price movement and volume into estimated buying and selling pressure. TradingView community versions can use different range denominators, smoothing, and output scales. Identify the author and formula before comparing readings. This oscillator does not locate supply and demand support zones or measure actual buyer-initiated versus seller-initiated trades.

See the decision guide

Public implementations are not interchangeable

Three inspectable references establish why the name alone is insufficient. These are implementation descriptions, not a claim that one version reproduces every historical Sibbet publication. The linked TradingView pages identify open-source community scripts; inspect the selected revision before using its values.

ReferenceIdentifiable calculation choiceComparison consequence
Sierra Chart study 139 and p_zerbst on TradingViewSierra documents a signed pressure ratio and H0 − L0 in the exponent. p_zerbst describes a port of that convention.Changing the first loaded bar can change the range reference.
ATAS public Demand.csThe inspected source uses the first candle range, volume EMA, pressure EMAs, and a separate DI SMA.Its range-EMA field does not establish a rolling-range calculation: OnCalculate does not update or use it.
TradeQUO Hybrid Sibbet on TradingViewThe author describes normalized volume, smoothed buy/sell powers, their difference, and optional final EMA smoothing.A pressure difference has a different scale from a signed ratio. Do not transfer thresholds.

Separate price range from volume normalization

For the Sierra documented convention, set P = H + L + 2C, A = EMA(volume, n), and U = volume / A. Let Pprev be the preceding P and R0 = first loaded high − first loaded low. With positive prices and R0 > 0, the exponential factor is E = 0.375 × (P + Pprev) / R0 × abs(P − Pprev) / min(P, Pprev).

  • On a rise: raw buy power = U and raw sell power = U × exp(−E). On a fall, exchange those assignments. When P is unchanged, both equal U.
  • Smooth raw powers into B and S. If B > S, DI = 100 × (1 − S/B); if S > B, DI = −100 × (1 − B/S); equal powers give zero. A separate SMA can be plotted as a signal line.
  • Sierra also defines a two-bar range: max(current high, previous high) − min(current low, previous low), and its average. Its displayed pressure equations nevertheless use R0. Replacing R0 with that average creates a different specification.
  • P is a sum, not the weighted average P/4. Substituting P/4 everywhere while retaining the 0.375 factor and the same range divides E by four.

Recalculate a normal bar and a volume spike

These are hypothetical one-step tests, each starting from the same prior states: volume EMA = 1000, B = S = 1, previous H/L/C = 101/99/100, and R0 = 4 from an earlier first bar. Use length 3 for the volume and pressure EMAs, so each update has weight 2/(3+1) = 0.5. The prior states are supplied, not initialized from these few rows. Both current bars have H/L/C = 102/100/101, making Pprev = 400, P = 404, and E = 0.75375.

  • Normal bar: S = 0.5 × exp(−0.75375) + 0.5 × 1 = 0.735299. Then DI = 100 × (1 − S/1).
  • The 10-fold volume spike does not make U ten times larger because the current bar also raises its EMA denominator. Using the previous EMA instead would give U = 10 and would change the result.
  • If pressure smoothing were removed, U would cancel from the ratio on this single bar. With prior smoothed states, larger volume gives the current pressure imbalance more weight. Volume is therefore not an independent direction signal.
QuantityNormal volume: 1000Spike volume: 10000
Updated volume EMA A10005500
U = volume / A1.0000001.818182
Raw buy / sell powers1 / 0.4705981.818182 / 0.855634
Updated B / S1 / 0.7352991.409091 / 0.927817
DI before signal SMA26.47007534.154936

Test gaps and zero ranges explicitly

These independent cases reuse the prior states above and volume 1000. They test formula behavior, not a market forecast. Rounded results refer to the unsignaled DI; the extra SMA would require its own preceding history.

  • ATAS includes fallback branches using the previous volume EMA. That behavior is separate from the displayed normal-case equations and still needs a nonzero denominator.
  • For a custom implementation, reject missing or nonpositive price denominators and nonfinite intermediate values. Very large exponents require a documented numerical policy; silently clipping them changes exact results.
  • A zero current volume with a positive historical average gives zero raw powers. Prior pressure EMA states can persist, so the displayed DI need not become zero immediately.
CaseInput and calculationResult or boundary
Gap upCurrent H/L/C = 112/110/111. P = 444; two-bar range = 112 − 99 = 13; R0 remains 4. E = 8.70375.B = 1, S = 0.500083, DI = 49.991702. The gap almost eliminates raw sell power, while old smoothed pressure remains.
Current bar has no rangeCurrent H = L = C = 100. P = Pprev = 400; R0 remains 4.E = 0, raw powers = 1, and DI = 0 under the supplied equal prior states. A zero current range alone does not divide by zero here.
First loaded bar has no rangeR0 = 0, even if the current bar has a normal range.The stated exponent is undefined. A custom implementation must disclose a fallback; it cannot claim unchanged formula equivalence.
No usable volume historyA = 0 or volume is missing.U is unavailable. Do not turn missing data into a valid zero-crossing signal.

Verify the TradingView version before using alerts

Select the exact community script and open its source. Compare its formulas against the reference you intend to reproduce, including its first-bar behavior. A matching title or length is not evidence of a matching algorithm. Keep a short worksheet of intermediate values alongside the chart.

  • Record symbol and exchange, chart interval, session, adjustment settings, available history start, author revision, and whether the volume field represents traded volume or another feed-specific measure.
  • Expose P, range reference, volume average, U, raw powers, B, S, and DI. Check a rising bar, falling bar, gap, high-volume bar, and a zero-range case.
  • Reload with more history. A first-bar range convention may change R0, independently of ordinary EMA warm-up differences. Record the first bar instead of assuming a longer warm-up removes this dependency.
  • Use completed chart bars for comparison. TradingView documents that realtime high, low, close, and volume can change before confirmation. Recheck alert timing after any change to timeframe or calculation context.
  • Define a zero crossing separately from remaining above zero. Positive DI means modeled B exceeds S; it does not guarantee the next price move or identify a support zone.

Give Pineify the public formula and its boundary policy

The Pine Script AI Coding Agent can draft and revise indicator code from a written specification. Supply the chosen public source, range convention, smoothing lengths, EMA seed, invalid-data behavior, and completed-bar alert rule. Ask for intermediate outputs so the generated code can be checked against the arithmetic above.

  • Request syntax checking explicitly, then compare closed-bar values in TradingView before enabling alerts. Syntax validation does not establish numerical parity.
  • Treat a proprietary or protected script as unavailable source. A public algorithm can be implemented and tested, but matching a protected indicator cannot be promised from its name or screenshot.
Where Pineify fits

Pine Script AI Coding Agent

Draft a Demand Index from a specified public algorithm, inspect its intermediate calculations, and request syntax checking before chart comparison.

Draft a specified Demand Index

Frequently asked questions

Educational formula comparisons, not investment advice. All numerical samples are hypothetical. Demand Index readings do not guarantee reversals, trade execution, or returns.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.