OPEN-SOURCE SCRIPT
Demand Index

##Description:
This indicator is a precise Pine Script replica of the "Demand Index" (Study ID 139) as found in the Sierra Chart trading platform.
Originally developed by James Sibbet, the Demand Index combines price and volume data to measure buying and selling pressure. It is often considered a leading indicator, anticipating price trend changes by identifying divergences between the price action and the volume flow.
##Key Features & Formula Logic
This script strictly follows the official documentation provided by Sierra Chart to ensure the values match the original platform as closely as possible.
Specific calculation details included in this port:
- P(HL2C): Uses the weighted average (High + Low + 2*Close).
- Range Calculation: Uses a Moving Range based on Max(High, 2) - Min(Low, 2).
- The H0/L0 Factor: A unique characteristic of the Sierra Chart formula is the use of H0 and L0 (the High and Low of the first loaded bar in history) to scale the volatility exponent. This script replicates that behavior.
Note: Because H0 and L0 depend on the start of the loaded data, values may shift slightly if the amount of historical data on your chart changes. This is consistent with how the study behaves in Sierra Chart.
- Complex Weighting: Calculates "Buy Power" and "Sell Power" using the specific exponential decay formula outlined in SC ID 139.
##Settings (Inputs)
- Buy/Sell Power Length (nBS): Length for smoothing Volume and Range (Default: 19).
- Buy/Sell Power MA Length: Length for the smoothing of the calculated Buy/Sell Power (Default: 19).
- Demand Index MA Length: Length for the final Simple Moving Average (SMA) of the Demand Index (Default: 19).
- MA Type: Choose the smoothing algorithm for intermediate steps (EMA, SMA, WMA, RMA). Default is EMA.
##How to Trade / Interpret
- Divergence: The most powerful signal. If price makes a new High but the Demand Index fails to reach a new High, it suggests Buying Power is weakening (Bearish Divergence). Conversely for Bullish Divergence.
- Zero Line Cross: A cross above zero indicates Buy Power > Sell Power (Bullish). A cross below zero indicates Sell Power > Buy Power (Bearish).
Disclaimer: This script is for educational and analytical purposes only. It is a code conversion based on public documentation of Sierra Chart Study ID 139.
Sierra Chart, best trading software, EVER!
With the best datafeet. Denali Exchange Data Feed.
This indicator is a precise Pine Script replica of the "Demand Index" (Study ID 139) as found in the Sierra Chart trading platform.
Originally developed by James Sibbet, the Demand Index combines price and volume data to measure buying and selling pressure. It is often considered a leading indicator, anticipating price trend changes by identifying divergences between the price action and the volume flow.
##Key Features & Formula Logic
This script strictly follows the official documentation provided by Sierra Chart to ensure the values match the original platform as closely as possible.
Specific calculation details included in this port:
- P(HL2C): Uses the weighted average (High + Low + 2*Close).
- Range Calculation: Uses a Moving Range based on Max(High, 2) - Min(Low, 2).
- The H0/L0 Factor: A unique characteristic of the Sierra Chart formula is the use of H0 and L0 (the High and Low of the first loaded bar in history) to scale the volatility exponent. This script replicates that behavior.
Note: Because H0 and L0 depend on the start of the loaded data, values may shift slightly if the amount of historical data on your chart changes. This is consistent with how the study behaves in Sierra Chart.
- Complex Weighting: Calculates "Buy Power" and "Sell Power" using the specific exponential decay formula outlined in SC ID 139.
##Settings (Inputs)
- Buy/Sell Power Length (nBS): Length for smoothing Volume and Range (Default: 19).
- Buy/Sell Power MA Length: Length for the smoothing of the calculated Buy/Sell Power (Default: 19).
- Demand Index MA Length: Length for the final Simple Moving Average (SMA) of the Demand Index (Default: 19).
- MA Type: Choose the smoothing algorithm for intermediate steps (EMA, SMA, WMA, RMA). Default is EMA.
##How to Trade / Interpret
- Divergence: The most powerful signal. If price makes a new High but the Demand Index fails to reach a new High, it suggests Buying Power is weakening (Bearish Divergence). Conversely for Bullish Divergence.
- Zero Line Cross: A cross above zero indicates Buy Power > Sell Power (Bullish). A cross below zero indicates Sell Power > Buy Power (Bearish).
Disclaimer: This script is for educational and analytical purposes only. It is a code conversion based on public documentation of Sierra Chart Study ID 139.
Sierra Chart, best trading software, EVER!
With the best datafeet. Denali Exchange Data Feed.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。