# Technical Studies Reference

### Demand Index

This study calculates and displays James Sibbet's Demand Index and its Simple Moving Average.

Let $$H$$, $$L$$, $$C$$, and $$V$$ be random variables denoting the High Price, Low Price, Closing Price, and Volume, respectively, and let $$H_t$$, $$L_t$$, $$C_t$$, and $$V_t$$ be their respective values at Index $$t$$. We define the functions $$P^{(HL2C)}_t$$ and $$\textrm{Range}_t(H,L,2)$$ as follows.

$$P^{(HL2C)}_t = H_t + L_t + 2C_t$$

$$\textrm{Range}_t(H,L,2) = \max_t(H,2) - \min_t(H,2)$$

The second function above is the Moving Range with $$X^{(1)} = H$$, $$X^{(2)} = L$$, and $$n = 2$$. It is expressed in terms of a Moving Maximum and a Moving Minimum.

Let the Buy/Sell Power Length Input be denoted as $$n_{BS}$$. Then we denote the Exponential Moving Average of $$\textrm{Range}_t(H,L,2)$$ and $$V_t$$ at Index $$t$$ as $$\overline{\textrm{Range}}_t(H,L,2,n_{BS})$$ and $$\overline{V}_t(n_{BS})$$, respectively, and we compute them for $$t \geq 0$$ as follows.

$$\overline{\textrm{Range}}_t(H,L,2,n_{BS}) = EMA_t(\textrm{Range}(H,L,2), n_{BS})$$
$$\overline{V}_t(n_{BS}) = EMA_t(V, n_{BS})$$

We denote the Buy Power and Sell Power at Index $$t$$ as $$BP_t(n_{BS})$$ and $$SP_t(n_{BS})$$, respectively, and we compute them for $$t \geq 1$$ as follows.

$$\displaystyle{BP_t(n_{BS}) = \left\{ \begin{matrix} \left. \left(\frac{V_t}{\overline{V}_t(n_{BS})} \right) \middle/ \exp\left(0.375\cdot\frac{P^{(HL2C)}_t + P^{(HL2C)}_{t - 1}}{H_0 - L_0}\cdot\frac{P^{(HL2C)}_{t - 1} - P^{(HL2C)}_t}{P^{(HL2C)}_t}\right)\right. & P^{(HL2C)}_t < P^{(HL2C)}_{t - 1} \\ \frac{V_t}{\overline{V}_t(n_{BS})} & P^{(HL2C)}_t \geq P^{(HL2C)}_{t - 1} \end{matrix}\right .}$$

$$\displaystyle{SP_t(n_{BS}) = \left\{ \begin{matrix} \frac{V_t}{\overline{V}_t(n_{BS})} & P^{(HL2C)}_t \leq P^{(HL2C)}_{t - 1} \\ \left. \left(\frac{V_t}{\overline{V}_t(n_{BS})} \right) \middle/ \exp\left(0.375\cdot\frac{P^{(HL2C)}_t + P^{(HL2C)}_{t - 1}}{H_0 - L_0}\cdot\frac{P^{(HL2C)}_t - P^{(HL2C)}_{t - 1}}{P^{(HL2C)}_{t - 1}}\right)\right. & P^{(HL2C)}_t > P^{(HL2C)}_{t - 1} \end{matrix}\right .}$$

Let the Buy/Sell Power Moving Average Length Input be denoted as $$n_{\overline{BS}}$$. Then we denote the Exponential Moving Averages of the Buy and Sell Power as $$\overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right)$$ and $$\overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right)$$, respectively, and we compute them for $$t \geq 0$$ as follows.

$$\overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) = EMA_t\left(BP\left(n_{BS}\right), n_{\overline{BS}}\right)$$
$$\overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) = EMA_t\left(SP\left(n_{BS}\right), n_{\overline{BS}}\right)$$

Note: Depending on the setting of the Input Demand Index Moving Average Type, the Exponential Moving Averages in the above formulas could be replaced with Linear Regression Moving Averages, Simple Moving Averages, Weighted Moving Averages, Wilders Moving Averages, Simple Moving Averages - Skip Zeros, or Smoothed Moving Averages.

Next we define a Quotient function $$Q_t\left(n_{BS}, n_{\overline{BS}}\right)$$ as follows.

$$\displaystyle{Q_t\left(n_{BS}, n_{\overline{BS}}\right) = \left\{ \begin{matrix} \overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) / \overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) & \overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) > \overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) \\ 1 & \overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) = \overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) \\ \overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) / \overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) & \overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) < \overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) \end{matrix}\right .}$$

Let the Demand Index Moving Average Length Input be denoted as $$n_{\overline{DI}}$$. Then we denote the Demand Index and the Simple Moving Average of the Demand Index as $$DI_t\left(n_{BS}, n_{\overline{BS}}\right)$$ and $$\overline{DI}_t\left(n_{BS}, n_{\overline{BS}}, n_{\overline{DI}}\right)$$, respectively, and we compute them for $$t \geq n_{\overline{DI}}$$ as follows.

$$\displaystyle{DI_t\left(n_{BS}, n_{\overline{BS}}\right) = \left\{\begin{matrix} 100\left(1 - Q_t\left(n_{BS}, n_{\overline{BS}}\right)\right) & \overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) \leq \overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) \\ 100\left(Q_t\left(n_{BS}, n_{\overline{BS}}\right) - 1\right) & \overline{SP}_t\left(n_{BS}, n_{\overline{BS}}\right) > \overline{BP}_t\left(n_{BS}, n_{\overline{BS}}\right) \end{matrix}\right .}$$

$$\overline{DI}_t\left(n_{BS}, n_{\overline{BS}}, n_{\overline{DI}}\right) = SMA_t\left(DI\left(n_{BS}, n_{\overline{BS}}\right), n_{\overline{DI}}\right)$$

Note: The Simple Moving Average in the above formula is not affected by the setting of the Demand Index Moving Average Type Input.