Login Page - Create Account

Technical Studies Reference


Sinewave Indicator

This study calculates and displays a Sinewave Indicator for the data given by the Input Data Input. This study is an ACSIL implementation of the Indicator given in Figures 11.2 and 11.3 of the book Cybernetic Analysis for Stocks and Futures by John Ehlers.

On This Page

Support Function: Dominant Cycle Phase

Before discussing this study, we first give the mathematical details of one of its support functions, namely sc.DominantCyclePhase().

Let \(X\) be any random variable, and let \(X_t\) be the value of \(X\) at Index \(t\).

The function sc.DominantCyclePhase computes the following quantities.

We begin by defining the Dominant Cycle Phase Period, denoted as \(T_t^{(DCP)}(X)\), and we compute it as follows.

\(T_t^{(DCP)}(X) = \lfloor X_t \rfloor \)

For an explanation of the floor function (\(\left\lfloor{\space\space}\right\rfloor\)), refer to our description here.

Next, we define an Angle, denoted as \(\theta_t(X,k)\), and we compute it as follows.

\(\displaystyle{\theta_t(X,k) = \left\{ \begin{matrix} \frac{360^\circ\cdot k}{T_t^{(DCP)}(X)} & T_t^{(DCP)}(X) \neq 0 \\ 0^\circ & T_t^{(DCP)}(X) = 0 \end{matrix}\right .}\)

The underlying calculation involves a complex-valued quantity that has both real and imaginary parts. We denote these parts as \(Re_t(X)\) and \(Im_t(X)\), respectively, and we compute them as follows.

\(\displaystyle{Re_t(X) = \sum_{k = 0}^{T_t^{(DCP)}(X) - 1} \sin(\theta_t(X,k)) \cdot X_{t - k}}\)
\(\displaystyle{Im_t(X) = \sum_{k = 0}^{T_t^{(DCP)}(X) - 1} \cos(\theta_t(X,k)) \cdot X_{t - k}}\)

Next, we define the Raw Dominant Cycle Phase, denoted as \(\phi_t^{(Raw)}(X)\), and we compute it (in degrees) as follows.

\(\displaystyle{\phi_t^{(Raw)}(X) = \left\{ \begin{matrix} \tan^{-1}\left(\frac{Re_t(X)}{Im_t(X)}\right) & |Im_t(X)| > 0.001 \\ \mathrm{sgn}(Re_t(X))\cdot 90^\circ & |Im_t(X)| \leq 0.001 \space and \space Re_t(X) \neq 0 \\ 0^\circ & |Im_t(X)| \leq 0.001 \space and \space Re_t(X) = 0 \end{matrix}\right .}\)

In the above calculation, \(\mathrm{sgn}()\) denotes the signum function, which returns the sign of its parameter.

Finally, we denote the Dominant Cycle Phase as \(\phi_t^{(DC)}(X)\), and we compute it as follows.

\(\displaystyle{\phi_t^{(DCP)}(X) = \left\{ \begin{matrix} \phi_t^{(Raw)}(X) + 180^\circ & Im_t(X) < 0^\circ \\ \phi_t^{(Raw)}(X) & 0^\circ \leq Im_t(X) \leq 315^\circ \\ \phi_t^{(Raw)}(X) - 360^\circ & Im_t(X) > 315^\circ \end{matrix}\right .}\)

Main Study Function: Sinewave Indicator

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 and Median Phase Change Length Inputs be denoted as \(n_{CC}\) and \(n_{Med}\), respectively.

We first smooth the data using a Four Bar Symmetrical Finite Impulse Response Filter. The value of the smoothed data at Index \(t\) is denoted as \(X^{(S)}_t\), and we compute it as follows.

\(\displaystyle{X^{(S)}_t = \frac{1}{6}(X_t + 2X_{t - 1} + 2X_{t - 2} + X_{t - 3})}\)

We then compute the Cyber Cycle, \(CC_t(X,n_{CC})\).

Next, we apply the Dominant Cycle Period to obtain \(T_t^{(DC)}(CC(X,n_{CC}),n_{Med})\).

We then denote the Sinewave Indicator as \(SWI_t(X,n_{CC},n_{Med})\), and we compute it as follows.

\(\displaystyle{SWI_t(X,n_{CC},n_{Med}) = \sin\left(T_t^{(DCP)}(X)\right)}\)

Finally, we denote the Lead Sinewave Oscillator as \(SWI_t^{(Lead)}(X,n_{CC},n_{Med})\), and we compute it as follows.

\(\displaystyle{SWI_t^{(Lead)}(X,n_{CC},n_{Med}) = \sin\left(T_t^{(DCP)}(X) + 45^\circ\right)}\)

Both \(SWI_t(X,n_{CC},n_{Med})\) and \(SWI_t^{(Lead)}(X,n_{CC},n_{Med})\) are displayed as Subgraphs.

Inputs


*Last modified Monday, 03rd October, 2022.