Moving Averages

Moving Average Crossover

This study displays two moving averages, whose types are chosen by the user with the Inputs Moving Average Type 1 and Moving Average Type 2. By default, both moving averages are Simple Moving Averages. The Inputs Input Data 1 and Input Data 2 are denoted as $$X_1$$ and $$X_2$$, respectively, and the Inputs Length 1 and Length 2 of these two moving averages are denoted as $$n_1$$ and $$n_2$$, respectively.

This study also displays signals to buy (indicated by an "up" arrow) or sell (indicated by a "down" arrow) at chart bar $$t$$. The conditions that determine which signal, if any, is displayed are stated below.

An "up" arrow is displayed at chart bar $$t$$ if either of the following occurs.

• $$n_1 < n_2$$ and the Subgraph of $$MA_t\left(X_1,n_1\right)$$ crosses the Subgraph of $$MA_t\left(X_2,n_2\right)$$ from below at chart bar $$t$$.
• $$n_2 < n_1$$ and the Subgraph of $$MA_t\left(X_2,n_2\right)$$ crosses the Subgraph of $$MA_t\left(X_1,n_1\right)$$ from below at chart bar $$t$$.

In each of the above two cases, the tip of the arrow coincides with the bottom of chart bar $$t$$.

A "down" arrow is displayed at chart bar $$t$$ if either of the following occurs.

• $$n_1 > n_2$$ and the Subgraph of $$MA_t\left(X_1,n_1\right)$$ crosses the Subgraph of $$MA_t\left(X_2,n_2\right)$$ from below at chart bar $$t$$.
• $$n_2 > n_1$$ and the Subgraph of $$MA_t\left(X_2,n_2\right)$$ crosses the Subgraph of $$MA_t\left(X_1,n_1\right)$$ from below at chart bar $$t$$.

In each of the above two cases, the tip of the arrow coincides with the top of chart bar $$t$$.

Note: Depending on the setting of the Inputs Moving Average Types 1 and 2, the Simple Moving Averages in the above paragraphs 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.

Moving Average Difference

To familiarize yourself with the terminology and notation used in this study, refer to the documentation for the study Moving Average - Simple.

This study displays the difference between two moving averages, whose types are chosen by the user with the Input Moving Average Type. By default, both moving averages are Simple Moving Averages. The Input Input Data is denoted as $$X$$, and the Inputs Length 1 and Length 2 of these two moving averages are denoted as $$n_1$$ and $$n_2$$, respectively.

We denote the Moving Average Difference at chart bar $$t$$ for the given Inputs as $$MADiff_t\left(X,n_1,n_2\right)$$, and we compute it as follows.

$$MADiff_t\left(X,n_1,n_2\right) = MA_t\left(X,n_1\right) - MA_t\left(X,n_2\right)$$

The Subgraph of this indicator is displayed in two user-selected colors: one for when the Subgraph is rising, and the other for when it is falling.

Note: Depending on the setting of the Inputs Moving Average Types 1 and 2, the Simple Moving Averages in the above formula 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.

Moving Average Envelope

The Moving Average Envelope study draws a top and bottom band or envelope above and below the moving average. Each of the bands are the specified Fixed Value from the moving average or the specified Percentage from the moving average.

Inputs

• Input Data
• Percentage or Fixed Value: Select either Percentage or Fixed Value. In the case of Percentage, set the percentage with the Percentage Input. In the case of Fixed Value, set the fixed value with the Fixed Value Input.
• Percentage: If Percentage or Fixed Value is set to Percentage, enter the percentage with this Input to multiply the moving average by. This result is added and subtracted to/from the moving average. 0.01 = 1%.
• Fixed Value: If Percentage or Fixed Value is set to Fixed Value, enter the fixed value with this Input to add and subtract this fixed value to/from the moving average.
• Moving Average Type
• Moving Average Length

This study calculates and displays an Adaptive Moving Average of the data specified by the Input Data Input. This moving average was developed by Perry Kaufman. Reference: Stocks & Commodities V13:6: (267): Sidebar: Adaptive Moving Average.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of the Input Data at Index $$t$$. Let the Inputs Fast Smoothing Constant and Slow Smoothing Constant be denoted as $$c_F$$ and $$c_S$$, respectively, and let the Input Length be denoted as $$n$$. We denote the values of the Direction, Volatility, and Smoothing Constant for the given Inputs at Index $$t$$ as $$Dir_t(X,n)$$, $$Vol_t(X,n)$$, and $$c_t(X,n)$$, respectively. We compute these for $$t \geq n$$ as follows.

$$Dir_t(X,n) = X_t - X_{t-n}$$

$$\displaystyle{Vol_t(X,n) = \left\{ \begin{matrix} 0.000001 & \sum_{i=t-n+1}^t\left|X_i - X_{i-1}\right| = 0 \\ \sum_{i=t-n+1}^t\left|X_i - X_{i-1}\right| & \sum_{i=t-n+1}^t\left|X_i - X_{i-1}\right| \neq 0 \end{matrix}\right .}$$

$$\displaystyle{c_t(X,n) = \left[\left|\frac{Dir(X,n)_t}{Vol(X,n)_t}\right|\left(\frac{2}{c_F + 1} - \frac{2}{c_S + 1}\right) + \frac{2}{c_S + 1}\right]^2}$$

We denote the Moving Average - Adaptive at Index $$t$$ for the given Inputs as $$AMA_t\left(X,n,c_F,c_S\right)$$, and we compute it with the following recursion relation.

For $$t < n$$: $$AMA_t\left(X,n,c_F,c_S\right) = 0$$

For $$t \geq n$$: $$\displaystyle{AMA_t\left(X,n,c_F,c_S\right) = \left\{ \begin{matrix} X_{t-1} + c_t(X,n)\cdot\left(X_t - X_{t - 1}\right) & AMA_{t-1}\left(X,n,c_F,c_S\right) = 0 \\ AMA_{t-1}\left(X,n,c_F,c_S\right) + c_t(X,n)\cdot(X_t - AMA_{t-1}\left(X,n,c_F,c_S\right)) & AMA_{t-1}\left(X,n,c_F,c_S\right) \neq 0 \end{matrix}\right.}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Moving Average - Adaptive Binary Wave

This study calculates the binary wave for Kaufman's Adaptive Moving Average. Refer to that study to familiarize yourself with the notation used here.

Just as with the Adaptive Moving Average, this study relies on the Inputs Input Data $$X$$, Length $$n$$, Fast Smoothing Constant $$c_F$$, and Slow Smoothing Constant $$c_S$$. The study also has an additional Input, namely the Filter Percentage $$f$$.

For the given Inputs, the Variance $$Var_t(X,n)$$ and Standard Deviation $$\sigma_t(X,n)$$ are calculated in terms of Simple Moving Averages at chart bar $$t$$ as follows.

$$Var_t(X,n) = MA_t\left(X^2,n\right) - \left(MA_t(X,n)\right)^2$$

$$\sigma_t(X,n) = \sqrt{Var_t(X,n)}$$

Next we define two functions $$AMALow_t(X,n)$$ and $$AMAHigh_t(X,n)$$ at chart bar $$t$$ as follows.

For $$t = 0$$:

$$AMALow_0(X,n) = AMAHigh_0(X,n) = AMA_0(X,n)$$

For $$t > 0$$:

$$\displaystyle{AMALow_t(X,n) = \left\{ \begin{matrix} AMA_t(X,n) & AMA_t(X,n) < AMA_{t-1}(X,n) \\ AMALow_{t-1}(X,n) & AMA_t(X,n) \geq AMA_{t-1}(X,n) \end{matrix}\right .}$$

$$\displaystyle{AMAHigh_t(X,n) = \left\{ \begin{matrix} AMAHigh_{t-1}(X,n) & AMA_t(X,n) \leq AMA_{t-1}(X,n) \\ AMA_t(X,n) & AMA_t(X,n) > AMA_{t-1}(X,n) \end{matrix}\right .}$$

The function $$AMALow$$ only changes value if the Adaptive Moving Average decreases from chart bar $$t-1$$ to chart bar $$t$$. The function $$AMAHigh$$ only changes value if the Adaptive Moving Averaage increases from chart bar $$t-1$$ to chart bar $$t$$.

Finally, the Binary Wave is calculated. We denote the value of the Binary Wave at chart bar $$t$$ for the given Inputs as $$BW_t(X,n,f)$$, and we compute it as follows.

$$\displaystyle{BW_t(X,n,f) = \left\{ \begin{matrix} 1 & AMA_t(X,n) - AMALow_t(X,n) > \frac{f}{100}\sigma_t(X,n) \\ -1 & AMAHigh_t(X,n) - AMA_t(X,n) > \frac{f}{100}\sigma_t(X,n) \\ 0 & otherwise \end{matrix}\right.}$$

Inputs

• Input Data
• Length
• Fast Smoothing Constant: This is the Length of a fast-moving Exponential Moving Average. It should be set to a value that is less than that of the Input Slow Smoothing Constant to obtain sensible results.
• Slow Smoothing Constant: This is the Length of a slow-moving Exponential Moving Average.
• Filter Percent: This Input, together with the Standard Deviation, determines the lower bound on both $$AMA_t(X,n) - AMALow_t(X,n)$$ and $$AMAHigh_t(X,n) - AMA_t(X,n)$$, which in turn determine the value of $$BW_t(X,n,f)$$.

Moving Average - Double Exponential

This study calculates a double exponential moving average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of the Input Data at chart bar $$t$$. Let the Input Length be denoted as $$n$$. Then we denote the Moving Average - Double Exponential at chart bar $$t$$ for the given Inputs as $$DEMA_t (X,n)$$, and we compute it in terms of the Exponential Moving Averages $$EMA_t(X,n)$$ and $$EMA_t(EMA(X,n),n)$$, where $$EMA(X,n)$$ is a random variable denoting the Exponential Moving Average of Length $$n$$ for the Input Data $$X$$. The two exponential moving averages are initialized as follows.

$$EMA_0(X,n) = EMA_0(EMA(X,n),n) = X_0$$

The Moving Average - Double Exponential is calculated from these exponential moving averages as follows.

$$DEMA_t(X,n) = 2EMA_t(X,n) - EMA_t(EMA(X,n),n)$$

Moving Average - Exponential

This study calculates and displays an Exponential Moving Average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of the Input Data at Index $$t$$. Let the Input Length be denoted as $$n$$. Then we denote the Moving Average - Exponential at Index $$t$$ for the given Inputs as $$EMA_t (X,n)$$, and we compute it as follows.

For $$t < n - 1$$: $$EMA_t(X,n) = 0$$

For $$t \geq n - 1$$: $$\displaystyle{EMA_t(X,n) = \left\{ \begin{matrix} cX_t + (1 - c)X_{t - 1} & EMA_{t - 1}(X,n) = 0 \\ cX_t + (1 - c)EMA_{t - 1} & EMA_{t - 1}(X,n) \neq 0 \end{matrix}\right .}$$

The constant $$c$$ is a Smoothing Constant between $$0$$ and $$1$$, and is related to the Input Length via $$c = \frac{2}{n+1}$$.

Note: For the purposes of computing $$EMA_t(X,n)$$ for $$t \geq n - 1$$, we use the following internal calculations for $$1 \leq t < n -1$$. These values are not returned as output.

$$\displaystyle{EMA_t(X,n) = \left\{\begin{matrix} \left(\frac{2}{t + 2}\right)X_t + \left(1 - \frac{2}{t + 2}\right)X_{t - 1} & EMA_{t - 1}(X,n) = 0 \\ \left(\frac{2}{t + 2}\right)X_t + \left(1 - \frac{2}{t + 2}\right)EMA_{t - 1} & EMA_{t - 1}(X,n) \neq 0 \end{matrix}\right .}$$

The higher the setting for the Length Input, the increase in sensitivity with the exponential moving average calculation to past values, as the amount of historical data in the chart changes. Even bar values which are outside the range of bars used in the calculation have an effect upon the exponential moving average values. The exponential moving average calculation uses the prior exponential value in its calculation, and so prior values have a continuous effect going back all the way to the first bar in the chart.

Therefore, merely by changing the Chart >> Chart Settings >> Use Number of Days to Load >> Days to Load, for a long Length exponential moving average will alter the result at a particular chart column even though the days removed or loaded in the chart is prior to the exponential moving average value at a particular chart column going back by the number of bars specified by the Length Input.

This is something important understand about the nature of the exponential calculation and you should question as to whether it is even an appropriate calculation method for your method of analysis. The exponential moving average should not be used with long Lengths. Instead use Moving Average - Simple.

Moving Average - Hull

This study calculates and displays a Hull Moving Average of the data specified by the Input Data Input. This moving average was developed by Alan Hull.

Let $$X$$ be a random variable denoting the Input Data, and let the Input Hull Moving Average Length be denoted as $$n$$. Let $$WMA\left(X,\left\lfloor{\frac{n}{2}+\frac{1}{2}}\right\rfloor\right)$$ and $$WMA(X,n)$$ be random variables denoting the Weighted Moving Averages for $$X$$ with Lengths $$\left\lfloor{\frac{n}{2}+\frac{1}{2}}\right\rfloor$$ and $$n$$, respectively. Then we denote the Moving Average - Hull at Index $$t$$ for the given Inputs as $$HMA_t(X,n)$$, and we compute it for $$t \geq n + \left\lfloor{\sqrt{n}+\frac{1}{2}}\right\rfloor - 1$$ as follows.

$$HMA_t(X,n) = WMA_t\left(2WMA\left(X, \left\lfloor{\frac{n}{2}+\frac{1}{2}}\right\rfloor\right) - WMA(X,n), \left\lfloor{\sqrt{n}+\frac{1}{2}}\right\rfloor\right)$$

For an explanation of the floor function ($$\left\lfloor{\space\space}\right\rfloor$$), refer to the Wikipedia article Floor and ceiling functions.

Moving Average - Rolling High Accuracy

The Moving Average - Rolling High Accuracy calculates at each chart bar, an average of all of the prices which make up the chart bars over the specified time period. This study relies on the underlying Volume at Price data in the chart to achieve its high accuracy.

It is necessary for Sierra Chart to be configured for a tick by tick data configuration for the study to it achieve its high accuracy.

To do Weekly and Monthly time periods with this study does not make sense with a rolling calculation because this study does not reference specific segments of time like the start of the week or the start of the month. Instead it back references data at each chart bar by the specified time period. Therefore, just simply set the Time Period Length and Time Period Type Inputs with the study to 7 Days or 30 Days respectively to effectively accomplish this.

If you have set the Time Period Type and Time Period Length Inputs so that the Moving Average calculation is across a large number of bars in the chart and there is a large number of bars loaded into the chart based upon the current Chart Settings, then the study can take an extended time to do the initial calculations and the program user interface will be frozen during this time. Therefore, it is necessary to be careful with these Input settings in order to not put too much of a processing burden on the program.

Inputs

• Time Period Type: This Input specifies the time period type. It can be either Days, Minutes, or Bars. When set to Bars, then this means the number of bars set by the Time Period Length will be used in the calculation.

When this Input is set to Days, the Time Period Length specifies the number of Trading days the calculation is performed over. Trading days are determined using the Session Times. For example, if Time Period Length is set to 2, then the prior trading day as determined by the Session Times, and all of the current trading day is included in the calculation. Therefore, it is not in this case a 2 day trailing calculation going back 48 hours from the current Date-Time.
• Time Period Length: This Input specifies the number of Days, Minutes or Bars depending upon whether Time Period Type is set to Days, Minutes or Bars.
• Exclude Weekends in Day Count: When this Input is set to Yes, Saturday and Sundays are skipped when determining how many days back to include in the calculation according to the Time Period Length Input.
• Use Fixed Offset Instead of Std. Deviation: .
• Band 1 Std. Deviation Multiplier/Fixed Offset: .
• Band 2 Std. Deviation Multiplier/Fixed Offset: .
• Band 3 Std. Deviation Multiplier/Fixed Offset: .
• Band 4 Std. Deviation Multiplier/Fixed Offset: .

Moving Average - Simple

This study calculates and displays a Simple Moving Average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_i$$ be the value of the Input Data at Index $$i$$. Let the Input Length be denoted as $$n$$. Then we denote the Moving Average - Simple at Index $$t$$ for the given Inputs as $$MA_t(X,n)$$, and we compute it for $$t \geq n - 1$$ as follows.

$$\displaystyle{MA_t(X,n) = \left. \left(\sum_{i = t - n + 1}^tX_i\right) \middle/ n\right.}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Moving Average - Simple Skip Zeros

This study calculates and displays a Simple Moving Average of the data specified by the Input Data Input, excluding the values that are equal to zero.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_i$$ be the value of the Input Data at Index $$i$$. Let the Input Length be denoted as $$n$$, and let the number of nonzero values of $$X$$ from $$X_{t-n+1}$$ through $$X_t$$ be denoted as $$n_{NZ}$$. Then we denote the Moving Average - Simple Skip Zeros at Index $$t$$ for the given Inputs as $$SZMA_t(X,n)$$, and we compute it for $$t \geq n - 1$$ as follows.

$$\displaystyle{SZMA_t(X,n) = \left. \left(\sum_{i = t - n + 1}^tX_i\right) \middle/ n_{NZ}\right.}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Moving Average - Sine-Wave Weighted

This study calculates a sine-wave weighted moving average of the data specified by the Input Input Data.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_i$$ be the value of the Input Data at chart bar $$i$$. Then we denote the Moving Average - Sine-Wave Weighted at chart bar $$t$$ for the given inputs as $$SWWMA_t(X)$$, and we compute it as follows.

$$\displaystyle{SWWMA_t(X) = \left. \left(\sum_{i=1}^5\sin\left(\frac{i\pi}{6}\right)X_{t-i+1}\right) \middle/ \left(\sum_{i=1}^5\sin\left(\frac{i\pi}{6}\right)\right) \right.}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Moving Average - Smoothed

This study calculates a smoothed moving average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_i$$ be the value of the Input Data at chart bar $$i$$. Let the Input Length be denoted as $$n$$. Then we denote the Moving Average - Smoothed at chart bar $$t$$ for the given Inputs as $$SMMA_t(X,n)$$, and we compute it with the following recursion relation.

$$SMMA_0(X,n) = 0$$
$$\displaystyle{SMMA_t(X,n) = \left. \left(\sum_{i=t-n}^{t-1}X_i - SMMA_{t-1}(X,n) + X_t\right) \middle/ n\right.}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Inputs

• Input Data
• Length
• Offset: This Input specifies the number of chart bars by which the summation index is to be shifted to the left.

Moving Average - Triangular

The Triangular Moving Average is calculated in terms of the Simple Moving Average. Refer to that study to familiarize yourself with the notation used here.

Just as with the Simple Moving Average, this study relies on the Inputs Data Input $$X$$ and Length $$n$$. We calculate two additional Lengths, $$n_1$$ and $$n_2$$, as follows.

$$\displaystyle{n_1 =\left\{ \begin{matrix} \left\lceil{\frac{n}{2}}\right\rceil & n \space odd\\ \frac{n}{2} & n \space even \end{matrix}\right .}$$

$$\displaystyle{n_2 =\left\{ \begin{matrix} \left\lceil{\frac{n}{2}}\right\rceil & n \space odd\\ n_1 + 1 & n \space even \end{matrix}\right .}$$

For an explanation of the ceiling function ($$\left\lceil{\space\space}\right\rceil$$), refer to the Wikipedia article Floor and ceiling functions.

We denote the Moving Average - Triangular at chart bar $$t$$ for the given Input Data and calculated Lengths as $$TMA_t\left(X,n_1,n_2\right)$$, and we compute it as follows.

$$TMA_t\left(X,n_1,n_2\right) = MA_t\left(MA\left(X,n_1\right),n_2\right)$$ In the above formula, $$MA\left(X,n_1\right)$$ is a random variable denoting the Simple Moving Average of Length $$n_1$$ for the Input Data $$X$$.

Moving Average - Triple Exponential

This study calculates a triple exponential moving average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of the Input Data at chart bar $$t$$. Let the Input Length be denoted as $$n$$. Then we denote the Moving Average - Triple Exponential at chart bar $$t$$ for the given Inputs as $$TEMA_t (X,n)$$, and we compute it in terms of the Exponential Moving Averages $$EMA_t(X,n)$$, $$EMA_t(EMA(X,n),n)$$, and $$EMA(EMA(EMA(X,n),n),n),n)$$ where $$EMA(X,n)$$ is a random variable denoting the Exponential Moving Average of Length $$n$$ for the Input Data $$X$$. The three exponential moving averages are initialized as follows.

$$EMA_0(X,n) = EMA_0(EMA(X,n),n) = EMA_0(EMA(EMA(X,n),n),n) = X_0$$

The Moving Average - Triple Exponential is calculated from these exponential moving averages as follows.

$$TEMA_t(X,n) = 3EMA_t(X,n) - 3EMA_t(EMA(X,n),n) + EMA_t(EMA(EMA(X,n),n),n)$$

Moving Average - Volume Weighted

This study calculates and displays a Volume Weighted Moving Average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, let $$X_i$$ be the value of the Input Data at Index $$i$$, and let $$V_i$$ be the Volume at Index $$i$$. Let the Input Length be denoted as $$n$$. The Moving Average - Volume Weighted at Index $$t$$ for the given Inputs is denoted as $$VWMA_t(X,n)$$, and we compute it for $$t \geq n$$ as follows.

$$\displaystyle{VWMA_t(X,n) = \left. \left(\sum_{i=t-n+1}^tX_iV_i\right) \middle/ \sum_{i=t-n+1}^tV_i\right.}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Moving Average - Weighted

This study calculates and displays a Weighted Moving Average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_i$$ be the value of the Input Data at Index $$i$$. Let the Input Length be denoted as $$n$$. Then we denote the Moving Average - Weighted at Index $$t$$ for the given Inputs as $$WMA_t(X,n)$$, and we compute it for $$t \geq n - 1$$ as follows.

$$\displaystyle{WMA_t(X,n) = \left. \left(\sum_{i=t-n+1}^t(n - t + i)X_i\right) \middle/ \left(\frac{n(n+1)}{2}\right)\right.}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Moving Average - Welles Wilders

This study calculates and displays a Welles Wilders Moving Average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of the Input Data at Index $$t$$. Let the Input Length be denoted as $$n$$. Then we denote the Moving Average - Welles Wilders at Index $$t$$ for the given Inputs as $$WWMA_t(X,n)$$, and we compute it using the following recursion relation.

For $$t = 0$$: $$WWMA_0 = X_0$$

For $$t > 0$$: $$WWMA_t(X,n) =\left\{ \begin{matrix} SZMA_t(X,n) & WMMA_{t-1}(X,n) = 0 \\ WWMA_{t-1}(X,n) + \frac{1}{n}\left(X_t - WWMA_{t-1}(X,n)\right) & WWMA_{t-1}(X,n) \neq 0 \end{matrix}\right .$$

In the above function, $$SZMA_t(X,n)$$ refers to Moving Average - Simple Skip Zeros.

Moving Average - Zero Lag Exponential

This study calculates a zero lag exponential moving average of the data specified by the Input Data Input.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of the Input Data at chart bar $$t$$. Let the Input Zero Lag EMA Length be denoted as $$n$$. Then we denote the Moving Average - Zero Lag Exponential at chart bar $$t$$ for the given Inputs as $$ZLEMA_t(X,n)$$, and we compute it using the following recursion relation.

$$ZLEMA_0(X,n) = 0$$

$$ZLEMA_t(X,n) = c\left(2X_t - X_{t - L}\right) + (1 - c)ZLEMA{t-1}(X,n)$$

The constant $$L$$ is called the Lag, and it is computed as follows.

$$L = \left\lceil{\frac{n-1}{2}}\right\rceil$$

For an explanation of the ceiling function ($$\left\lceil{\space\space}\right\rceil$$), refer to the Wikipedia article Floor and ceiling functions.

The constant $$c$$ is the same multiplier that is found in the Exponential Moving Average.

If $$L = 0$$, then $$ZLEMA_t(X,n)$$ becomes identical to $$EMA_t(X,n)$$.

Moving Averages

This study calculates and draws 3 moving averages of any type.

Moving Linear Regression / Moving Average - Linear Regression

The Moving Linear Regression and the Moving Average - Linear Regression studies calculate and display the value of a linear regression function of the selected Input Data (Open, High, Low, Close) over the specified Length.

Therefore, any point along the Linear Regression study line is equal to the ending value of a Linear Regression line. For example, the ending value of a Linear Regression line that covers 10 closing prices will have the same value as a Moving Linear Regression line with a Length of 10 at the same bar.

For the calculation method, refer to the LinearRegressionIndicator_S function in the /ACS_Source/SCStudyFunctions.cpp file in the folder Sierra Chart is installed to.

If you draw a Linear Regression Chart Drawing over the same Length that you have set in the study Inputs for this study, then where that drawing ends, it will have the same value as the Moving Average - Linear Regression study.

Next we describe the calculation of the Linear Regression Indicator. Let $$T$$ be the variable measured along the horiztonal axis, let $$X$$ be a random variable denoting the Input Data, which is measured along the vertical axis. We denote the values of these variables at chart bar $$i$$ as $$T_i = i$$ and $$X_i$$, respectively , where $$i$$ is a running index. We denote the value of the index corresponding to the current bar as $$i = t$$. Let $$n$$ be the Input Length. The Linear Regression Indicator function computes each of the following sums at chart bar $$t$$. These sums are used to calculate the regression statistics.

$$\displaystyle{\left(sum_T\right)_t = \sum_{i=1}^n {i}=\frac{n(n+1)}{2}}$$
$$\displaystyle{\left(sum_T\right)^2_t=\left(\sum_{i=1}^n {i}\right)^2=\frac{n^2(n+1)^2}{4}}$$
$$\displaystyle{\left(sum_{T^2}\right)_t=\sum_{i=1}^n {i^2} = \frac{n(n+1)(2n+1)}{6}}$$
$$\displaystyle{\left(sum_X\right)_t=\sum_{i=t-n+1}^t {X_i}}$$
$$\displaystyle{\left(sum_{TX}\right)_t=\sum_{i=t-n+1}^t{T_iX_i}=\sum_{i=t-n+1}^t{(i-t+n)X_i}}$$

For an explanation of the Sigma ($$\Sigma$$) notation for summation, refer to the Wikipedia article Summation.

Note: The sums over the $$T-$$ values do not move, as the sums over the $$X-$$ values do. This is compensated for by using the Length $$n$$ in certain places instead of the current value $$t$$ of the Index. This always gives the correct value of the LRI and of the slope of the regression line, but it does not give the correct value of the intercept.

These sums are used to compute the regression statistics, as shown below.

Slope:

$$b_t = \frac{n \cdot \left(sum_{TX}\right)_t-\left(sum_T\right)_t \cdot \left(sum_X\right)_t}{n \cdot \left(sum_{T^2}\right)_t-(sum_T)^2_t}$$

Intercept:

$$a_t = \frac{\left(sum_X\right)_t - b_t \cdot \left(sum_T\right)_t}{n}$$

The regression model is of the form $$X = a_t + b_tT$$, where $$a_t$$ and $$b_t$$ are as defined above.

Linear Regression Indicator:

The Linear Regression Indicator is the $$X-$$coordinate of the right endpoint of the linear regression trendline of Length $$n$$. Its value $$LRI_t$$ at chart bar $$t$$ is calculated as $$LRI_t = a_t + b_tn$$.

The Moving Average - Linear Regression at chart bar $$t$$ for the given Inputs is denoted as $$LSMA_t(X,n) = a_t + b_tn$$

Study Moving Average

This study is for back-compatibility. You should use the new Based On setting for a study to base a study on another study. For more information, see Technical Study Settings.

T3

This study calculates a T3 moving average of the data specified by the Input Data Input. The study was developed by Tim Tillson.

Let $$X$$ be a random variable denoting the Input Data, and let $$X_t$$ be the value of the Input Data at chart bar $$t$$. Let the Input Length be denoted as $$n$$, and let Input Multiplier be denoted as $$v$$. Then we denote the value of T3 at chart bar $$t$$ for the given Inputs as $$T3_(X,n,v)$$, and we compute it using the following sequence of Exponential Moving Averages for the given Inputs. $$EMA_t^{(1)}(X,n) = EMA_t(X,n)$$
$$EMA_t^{(2)}(X,n) = EMA_t(EMA(X,n),n)$$
$$EMA_t^{(3)}(X,n) = EMA_t(EMA(EMA(X,n),n),n)$$
$$EMA_t^{(4)}(X,n) = EMA_t(EMA(EMA(EMA(X,n),n),n),n)$$
$$EMA_t^{(5)}(X,n) = EMA_t(EMA(EMA(EMA(EMA(X,n),n),n),n),n)$$
$$EMA_t^{(6)}(X,n) = EMA_t(EMA(EMA(EMA(EMA(EMA(X,n),n),n),n),n),n)$$

In the above relations, $$EMA_t^{(j)}$$ denotes the $$j-$$fold composition of the $$EMA$$ function with itself, and $$EMA(X,n)$$ is a random variable denoting the Exponential Moving Average of Length $$n$$ for the Input Data $$X$$. We compute $$T3_t$$(X,n,v)\) as follows.

$$T3_t(X,n,v) = -v^3EMA_t^{(6)}(X,n) + 3v^2(1+v)EMA_t^{(5)}(X,n) -v(1+v)^2EMA_t^{(4)}(X,n) + (1+v)^3EMA_t^{(3)}(X,n)$$