# Even Better Sinewave Indicator

This study calculates and displays an Even Better Sinewave Indicator (by John Ehlers) for the data given by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of $$X$$ at Index $$t$$. Let the Length Input be denoted as $$n)\. We begin by computing a constant that depends on the Length, which we denote as \(\alpha^{(1)}(n)$$.

$$\displaystyle{\alpha^{(1)}(n) = \frac{1 - \sin\left(\frac{360^\circ}{n}\right)}{\cos\left(\frac{360^\circ}{n}\right)}}$$

If $$\cos\left(\frac{360^\circ}{n}\right) = 0$$, then $$\alpha^{(1)}(n) = 0$$.

We denote the High Pass Filter at Index $$t$$ as $$HP_t(X,n)$$, and we compute it as follows.

$$\displaystyle{HP_t(X,n) = \frac{1}{2}\left(1 + \alpha^{(1)}(n)\right)\left(X_t - X_{t - 1}\right) + \alpha^{(1)}(n) \cdot HP_{t - 1}(X,n)}$$

Note: The lowest possible setting for $$n$$ is $$5$$. This is because $$\alpha^{(1)} = 0$$ for $$n = 2$$, and $$\alpha^{(1)}$$ is undefined for $$n = 4$$. The lower limit of $$5$$ is intended to prevent users from using either of these problematic settings.

Next, we compute a 2-bar Simple Moving Average of $$HP_t(X,n)$$, as follows.

$$\overline{HP}_t(X,n) = SMA_t(HP(X,n),3)$$

We then denote the the Wave Amplitude and Wave Power as $$A_t(X,n)$$ and $$P_t(X,n)$$, respectively, and we compute them using a 2-Pole Super Smoother Filter on $$\overline{HP}_t(X,n)$$, as follows.

$$A_t(X,n) = SSF^{(2)}_t\left(\overline{HP}(X,n),10\right)$$
$$P_t(X,n) = \left[A_t(X,n)\right]^2$$

We then compute the three-bar Simple Moving Averages of the Amplitude and Power, denoting these averages respectively as $$\overline{A}_t(X,n)$$ and $$\overline{P}_t(X,n)$$. We compute them as follows.

$$\overline{A}_t(X,n) = SMA_t(A(X,n),3)$$
$$\overline{P}_t(X,n) = SMA_t(P(X,n),3)$$

Finally, we denote the Even Better Sinewave Indicator as $$EBSWI_t(X,n)$$, and we compute it as follows.

$$\displaystyle{EBSWI_t(X,n) = \frac{\overline{A}_t(X,n)}{\sqrt{\overline{P}_t(X,n)}}}$$

If $$\overline{P}_t(X,n) = 0$$, then $$EBSWI_t(X,n) = 0$$.