# Elder Impulse

This study colors the bars of the Main Price Graph according to the Elder Impulse rules.

Let $$X$$ be a random variable denoting the Input Data Input. Let the Inputs Moving Average Length, Fast Moving Average Length, Slow Moving Average Length, and MACD Moving Average Length be denoted as $$n$$, $$n_F$$, $$n_S$$, and $$n_M$$, respectively.

The Elder Impulse rules are expressed in terms of the Exponential Moving Average and MACD. See the documentation of those studies for an explanation of the notation used here.

The Elder Impulse rules are as follows.

• If $$EMA_t(C,n) > EMA_{t - 1}(C,n)$$ and $$\Delta MACD_t(X,n_F,n_S,n_M) > \Delta MACD_{t - 1}(X,n_F,n_S,n_M)$$, then the color of the chart bar at Index $$t$$ is controlled by the Color 2 Input.
• If $$EMA_t(C,n) < EMA_{t - 1}(C,n)$$ and $$\Delta MACD_t(X,n_F,n_S,n_M) < \Delta MACD_{t - 1}(X,n_F,n_S,n_M)$$, then the color of the chart bar at Index $$t$$ is controlled by the Color 3 Input.
• If neither of the two above rules are satisfied, then the color of the chart bar at Index $$t$$ is controlled by the Color 1 Input.

Note: The Exponential Moving Averages in the above rules can be replaced with other moving averages depending on the setting of the Moving Average Type Input. The moving average type used in the MACD Difference is controlled by the MACD Moving Average Type Input.