OPEN-SOURCE SCRIPT
Telah dikemas kini

Demand Index (Hybrid Sibbet) by TradeQUO

121
Demand Index (Hybrid Sibbet) by TradeQUO \

\Overview\
The Demand Index (DI) was introduced by James Sibbet in the early 1990s to gauge “real” buying versus selling pressure by combining price‐change information with volume intensity. Unlike pure price‐based oscillators (e.g. RSI or MACD), the DI highlights moves backed by above‐average volume—helping traders distinguish genuine demand/supply from false breakouts or low‐liquidity noise.

\Calculation\
\

\[\*]\Step 1: Weighted Price (P)\
For each bar t, compute a weighted price:

```
Pₜ = Hₜ + Lₜ + 2·Cₜ
```

where Hₜ=High, Lₜ=Low, Cₜ=Close of bar t.
Also compute Pₜ₋₁ for the prior bar.

\[\*]\Step 2: Raw Range (R)\
Calculate the two‐bar range:

```
Rₜ = max(Hₜ, Hₜ₋₁) – min(Lₜ, Lₜ₋₁)
```

This Rₜ is used indirectly in the exponential dampener below.

\[\*]\Step 3: Normalize Volume (VolNorm)\
Compute an EMA of volume over n₁ bars (e.g. n₁=13):

```
EMA_Volₜ = EMA(Volume, n₁)ₜ
```

Then

```
VolNormₜ = Volumeₜ / EMA_Volₜ
```

If EMA\_Volₜ ≈ 0, set VolNormₜ to a small default (e.g. 0.0001) to avoid division‐by‐zero.

\[\*]\Step 4: BuyPower vs. SellPower\
Calculate “raw” BuyPowerₜ and SellPowerₜ depending on whether Pₜ > Pₜ₋₁ (bullish) or Pₜ < Pₜ₋₁ (bearish). Use an exponential dampener factor Dₜ to moderate extreme moves when true range is small. Specifically:

• If Pₜ > Pₜ₋₁,

```
BuyPowerₜ = (VolNormₜ) / exp[ 0.375 × ((Pₜ + Pₜ₋₁)/(H₀–L₀)) × ((Pₜ – Pₜ₋₁)/Pₜ₋₁) ]
```

otherwise

```
BuyPowerₜ = VolNormₜ.
```

• If Pₜ < Pₜ₋₁,

```
SellPowerₜ = (VolNormₜ) / exp[ 0.375 × ((Pₜ + Pₜ₋₁)/(H₀–L₀)) × ((Pₜ₋₁ – Pₜ)/Pₜ) ]
```

otherwise

```
SellPowerₜ = VolNormₜ.
```

Here, H₀ and L₀ are the very first bar’s High/Low—used to calibrate the scale of the dampening. If the denominator of the exponential is near zero, substitute a small epsilon (e.g. 1e-10).

\[\*]\Step 5: Smooth Buy/Sell Power\
Apply a short EMA (n₂ bars, typically n₂=2) to each:

```
EMA_Buyₜ = EMA(BuyPower, n₂)ₜ
EMA_Sellₜ = EMA(SellPower, n₂)ₜ
```

\[\*]\Step 6: Raw Demand Index (DI\_raw)\

```
DI_rawₜ = EMA_Buyₜ – EMA_Sellₜ
```

A positive DI\_raw indicates that buying force (normalized by volume) exceeds selling force; a negative value indicates the opposite.

\[\*]\Step 7: Optional EMA Smoothing on DI (DI)\
To reduce choppiness, compute an EMA over DI\_raw (n₃ bars, e.g. n₃ = 1–5):

```
DIₜ = EMA(DI_raw, n₃)ₜ.
```

If n₃ = 1, DI = DI\_raw (no further smoothing).
\

\Interpretation\
\

\[\*]\Crossing Zero Line\
• DI\_raw (or DI) crossing from below to above zero signals that cumulative buying pressure (over the chosen smoothing window) has overcome selling pressure—potential Long signal.
• Crossing from above to below zero signals dominant selling pressure—potential Short signal.

\[\*]\DI\_raw vs. DI (EMA)\
• When DI\_raw > DI (the EMA of DI\_raw), bullish momentum is accelerating.
• When DI\_raw < DI, bullish momentum is weakening (or bearish acceleration).

\[\*]\Divergences\
• If price makes new highs while DI fails to make higher highs (DI\_raw or DI declining), this hints at weakening buying power (“bearish divergence”), possibly preceding a reversal.
• If price makes new lows while DI fails to make lower lows (“bullish divergence”), this may signal waning selling pressure and a potential bounce.

\[\*]\Volume Confirmation\
• A strong price move without a corresponding rise in DI often indicates low‐volume “fake” moves.
• Conversely, a modest price move with a large DI spike suggests true institutional participation—often a more reliable breakout.
\

\Usage Notes & Warnings\
\

\[\*]\Never Use DI in Isolation\
It is a \filter\ and \confirmation\ tool—combine with price‐action (trendlines, support/resistance, candlestick patterns) and risk management (stop‐losses) before executing trades.

\[\*]\Parameter Selection\
• \Vol EMA length (n₁)\: Commonly 13–20 bars. Shorter → more responsive to volume spikes, but noisier.
• \Buy/Sell EMA length (n₂)\: Typically 2 bars for fast smoothing.
• \DI smoothing (n₃)\: Usually 1 (no smoothing) or 3–5 for moderate smoothing. Long DI\_EMA (e.g. 20–50) gives a slower signal.

\[\*]\Market Adaptation\
Works well in liquid futures, indices, and heavily traded stocks. In thinly traded or highly erratic markets, adjust n₁ upward (e.g., 20–30) to reduce noise.


---

\In Summary\
The Demand Index (James Sibbet) uses a three‐stage smoothing (volume → Buy/Sell Power → DI) to reveal true demand/supply imbalance. By combining normalized volume with price change, Sibbet’s DI helps traders identify momentum backed by real participation—filtering out “empty” moves and spotting early divergences. Always confirm DI signals with price action and sound risk controls before trading.
Nota Keluaran
Code performance has been improved

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.