# Technical Studies Reference

### DeMarker Oscillator Type II

This study calculates and displays a DeMarker Oscillator Type II (DeM-II) of the data specified by the Input Data High, Input Data Low, and Input Data Close Inputs. This is an oscillator that was developed by Thomas DeMark, and it is closely related to the DeMarker Oscillator Type I. See the documentation for that study for an explanation of the notation used here.

Let $$X^{(H)}$$, $$X^{(L)}$$, and $$X^{(C)}$$ be random variables denoting the Input Data High, Input Data Low, and Input Data Close, respectively, and let $$X^{(H)}_t$$, $$X^{(L)}_t$$, and $$X^{(C)}_t$$ be their respective values at Index $$t$$. We denote the Max DeMarker Type II and the Min DeMarker Type II at Index $$t$$ as $$DeMax^{(II)}_t\left(X^{(H)}, X^{(L)}, X^{(C)}, n^{(1)}_{DeM}\right)$$ and $$DeMin^{(II)}_t\left(X^{(H)}, X^{(L)}, X^{(C)}, n^{(1)}_{DeM}\right)$$, respectively, and we compute them for $$t \geq n^{(1)}_{DeM}$$ as follows.

$$DeMax^{(II)}_t\left(X^{(H)}, X^{(L)}, X^{(C)}, n^{(1)}_{DeM}\right) =\left\{ \begin{matrix} X^{(H)}_t - X^{(C)}_{t - n^{(1)}_{DeM}} + X^{(C)}_t - X^{(L)}_t & X^{(H)}_t - X^{(C)}_{t - n^{(1)}_{DeM}} + X^{(C)}_t - X^{(L)}_t > 0 \\ 0 & X^{(H)}_t - X^{(C)}_{t - n^{(1)}_{DeM}} + X^{(C)}_t - X^{(L)}_t \leq 0 \end{matrix}\right .$$

$$DeMin^{(II)}_t\left(X^{(H)}, X^{(L)}, X^{(C)}, n^{(1)}_{DeM}\right) =\left\{ \begin{matrix} X^{(C)}_{t - n^{(1)}_{DeM}} - X^{(L)}_t + X^{(H)}_t - X^{(C)}_t & X^{(C)}_{t - n^{(1)}_{DeM}} - X^{(L)}_t + X^{(H)}_t - X^{(C)}_t > 0 \\ 0 & X^{(C)}_{t - n^{(1)}_{DeM}} - X^{(L)}_t + X^{(H)}_t - X^{(C)}_t \leq 0 \end{matrix}\right .$$

The DeMarker Oscillator Type II at Index $$t$$ is denoted as $$DeM^{(II)}_t\left(X^{(H)}, X^{(L)}, X^{(C)}, n^{(1)}_{DeM}, n^{(2)}_{DeM}\right)$$, and it is computed for $$t \geq n^{(1)}_{DeM} + n^{(2)}_{DeM} - 1$$ as follows.

$$\displaystyle{DeM^{(II)}_t\left(X^{(H)}, X^{(L)}, X^{(C)}, n^{(1)}_{DeM}, n^{(2)}_{DeM}\right) = \left\{ \begin{matrix} 100\cdot\frac{\mathrm{sum}_t\left({DeMax}^{(II)}\left(X^{(H)}, X^{(L)}, X^{(C)},n^{(1)}_{DeM}\right), n^{(2)}_{DeM}\right)}{\mathrm{sum}_t\left({DeMax}^{(II)}\left(X^{(H)}, X^{(L)}, X^{(C)},n^{(1)}_{DeM}\right), n^{(2)}_{DeM}\right) + \mathrm{sum}_t\left({DeMin}^{(II)}\left(X^{(H)}, X^{(L)}, X^{(C)},n^{(1)}_{DeM}\right), n^{(2)}_{DeM}\right)} & \mathrm{sum}_t\left({DeMax}^{(II)}\left(X^{(H)}, X^{(L)}, X^{(C)},n^{(1)}_{DeM}\right), n^{(2)}_{DeM}\right) + \mathrm{sum}_t\left({DeMin}^{(II)}\left(X^{(H)}, X^{(L)}, X^{(C)},n^{(1)}_{DeM}\right), n^{(2)}_{DeM}\right) \neq 0 \\ {DeM}^{(II)}_{t - 1}\left(X^{(H)}, X^{(L)}, X^{(C)}, n^{(1)}_{DeM}, n^{(2)}_{DeM}\right) & \mathrm{sum}_t\left({DeMax}^{(II)}\left(X^{(H)}, X^{(L)}, X^{(C)},n^{(1)}_{DeM}\right), n^{(2)}_{DeM}\right) + \mathrm{sum}_t\left({DeMin}^{(II)}\left(X^{(H)}, X^{(L)}, X^{(C)},n^{(1)}_{DeM}\right), n^{(2)}_{DeM}\right) = 0 \end{matrix}\right .}$$

This notation will become more cumbersome as we proceed, so we will omit the function parameters when referring to DeM-II going forward.

Let the Smoothing Length Input be denoted as $$n_S$$, where $$n_S \leq n^{(2)}_{DeM}$$. If the Use Smoothing? Input is set to Yes, then the following Simple Moving Average replaces the normal DeM-II Oscillator, and we compute it for $$t \geq n^{(1)}_{DeM} + n^{(2)}_{DeM} + n_S - 2$$.

$$SMA_t\left(DeM^{(II)},n_S\right)$$

Let the Average DeM MA Length Input be denoted as $$n_{MA}$$, which need not be smaller than $$n^{(2)}_{DeM}$$. If the Use Moving Average? Input is set to Yes, then the DeM-II Subgraph is replaced with the following.

• $$SMA_t\left(DeM^{(I)},n_{MA}\right)$$ for $$t \geq n^{(1)} + \max\left\{n^{(2)}, n_{MA} - 1\right\}$$ if Use Smoothing? is set to No.
• $$SMA_t\left(SMA\left({DeM}^{(I)},n_S\right),n_{MA}\right)$$ for $$t \geq \max\left\{n^{(1)}, n_S\right\} + \max\left\{n^{(2)}, n_{MA} - 1\right\}$$ if Use Smoothing? is set to Yes.

Note: The Inputs Smoothing MA Type and Average DeM MA Type control the Moving Average Types of the Simple Moving Averages (SMAs) of Length $$n_S$$ and $$n_{MA}$$, respectively. Depending on the settings of these Inputs, the SMAs in the above functions could be replaced with Exponential Moving Averages, Linear Regression Moving Averages, Weighted Moving Averages, Wilders Moving Averages, Simple Moving Averages - Skip Zeros, or Smoothed Moving Averages.

This study also displays horizontal lines at levels determined by the Overbought Line Value and Oversold Line Value Inputs.

Let the Input Arrow Offset Percentage be denoted as $$k$$.

If the DeM-II breaks out above the Overbought Line for $$n_D$$ chart bars or more, then a green Down Arrow appears above the DeM-II Subgraph at a horizontal location $$n_D$$ bars from the left of where the breakout occurred. The vertical position of the arrow is given by $$DeM^{(II)}_T + \frac{k}{100} \cdot DeM^{(II)}_T$$, where $$T$$ is the value of the Index where the arrow is drawn.

If the DeM-II breaks out below the Oversold Line for $$n_D$$ chart bars or more, then a red Up Arrow appears below the DeM-II Subgraph at a horizontal location $$n_D$$ bars from the left of where the breakout occurred. The vertical position of the arrow is given by $$DeM^{(II)}_T + \frac{k}{100} \cdot DeM^{(II)}_T$$, where $$T$$ is the value of the Index where the arrow is drawn.