OPEN-SOURCE SCRIPT

Variety N-Tuple Moving Averages w/ Variety Stepping [Loxx] is a moving average indicator that allows you to create 1- 30 tuple moving average types; i.e., Double-MA, Triple-MA, Quadruple-MA, Quintuple-MA, ... N-tuple-MA. This version contains 2 different moving average types. For example, using "50" as the depth will give you Quinquagintuple Moving Average. If you'd like to find the name of the moving average type you create with the depth input with this indicator, you can find a list of tuples here: Tuples extrapolated

Due to the coding required to adapt a moving average to fit into this indicator, additional moving average types will be added as they are created to fit into this unique use case. Since this is a work in process, there will be many future updates of this indicator. For now, you can choose from either EMA or RMA.

This indicator is also considered one of the top 10 forex indicators. See details here: https://forex-station.com/viewtopic.php?t=8473244

Additionally, this indicator is a computationally faster, more streamlined version of the following indicators with the addition of 6 stepping functions and 6 different bands/channels types.

STD-Stepped, Variety N-Tuple Moving Averages [Loxx]

STD-Stepped, Variety N-Tuple Moving Averages is the standard deviation stepped/filtered indicator of the following indicator

Last but not least, a big shoutout to lejmer for his help in formulating a looping solution for this streamlined version. this indicator is speedy even at 50 orders deep. You can find his scripts here: https://www.tradingview.com/u/lejmer/#published-scripts

**How this works**

Step 1: Run factorial calculation on the depth value,

Step 2: Calculate weights of nested moving averages

factorial(depth) / (factorial(depth - k) * factorial(k); where depth is the depth and k is the weight position

Examples of coefficient outputs:

6 Depth: 6 15 20 15 6

7 Depth: 7 21 35 35 21 7

8 Depth: 8 28 56 70 56 28 8

9 Depth: 9 36 34 84 126 126 84 36 9

10 Depth: 10 45 120 210 252 210 120 45 10

11 Depth: 11 55 165 330 462 462 330 165 55 11

12 Depth: 12 66 220 495 792 924 792 495 220 66 12

13 Depth: 13 78 286 715 1287 1716 1716 1287 715 286 78 13

Step 3: Apply coefficient to each moving average

For QEMA, which is 5 depth EMA , the calculation is as follows

ema1 = ta. ema ( src , length)

ema2 = ta. ema (ema1, length)

ema3 = ta. ema (ema2, length)

ema4 = ta. ema (ema3, length)

ema5 = ta. ema (ema4, length)

In this new streamlined version, these MA calculations are packed into an array inside loop so Pine doesn't have to keep all possible series information in memory. This is handled with the following code:

temp = array.get(workarr, k + 1) + alpha * (array.get(workarr, k) - array.get(workarr, k + 1))

array.set(workarr, k + 1, temp)

After we pack the array, we apply the coefficients to derive the NTMA:

qema = 5 * ema1 - 10 * ema2 + 10 * ema3 - 5 * ema4 + ema5

**Stepping calculations**

First off, you can filter by both price and/or MA output. Both price and MA output can be filtered/stepped in their own way. You'll see two selectors in the input settings. Default is ATR ATR. Here's how stepping works in simple terms: if the price/MA output doesn't move by X deviations, then revert to the price/MA output one bar back.

**ATR**

The average true range (ATR) is a technical analysis indicator, introduced by market technician J. Welles Wilder Jr. in his book New Concepts in Technical Trading Systems, that measures market volatility by decomposing the entire range of an asset price for that period.

**Standard Deviation**

Standard deviation is a statistic that measures the dispersion of a dataset relative to its mean and is calculated as the square root of the variance. The standard deviation is calculated as the square root of variance by determining each data point's deviation relative to the mean. If the data points are further from the mean, there is a higher deviation within the data set; thus, the more spread out the data, the higher the standard deviation.

**Adaptive Deviation**

By definition, the Standard Deviation (STD, also represented by the Greek letter sigma σ or the Latin letter s) is a measure that is used to quantify the amount of variation or dispersion of a set of data values. In technical analysis we usually use it to measure the level of current volatility .

Standard Deviation is based on Simple Moving Average calculation for mean value. This version of standard deviation uses the properties of EMA to calculate what can be called a new type of deviation, and since it is based on EMA , we can call it EMA deviation. And added to that, Perry Kaufman's efficiency ratio is used to make it adaptive (since all EMA type calculations are nearly perfect for adapting).

The difference when compared to standard is significant--not just because of EMA usage, but the efficiency ratio makes it a "bit more logical" in very volatile market conditions.

See how this compares to Standard Devaition here:

Adaptive Deviation

**Median Absolute Deviation**

The median absolute deviation is a measure of statistical dispersion. Moreover, the MAD is a robust statistic, being more resilient to outliers in a data set than the standard deviation. In the standard deviation, the distances from the mean are squared, so large deviations are weighted more heavily, and thus outliers can heavily influence it. In the MAD, the deviations of a small number of outliers are irrelevant.

Because the MAD is a more robust estimator of scale than the sample variance or standard deviation, it works better with distributions without a mean or variance, such as the Cauchy distribution.

For this indicator, I used a manual recreation of the quantile function in Pine Script. This is so users have a full inside view into how this is calculated.

**Efficiency-Ratio Adaptive ATR**

Average True Range (ATR) is widely used indicator in many occasions for technical analysis . It is calculated as the RMA of true range. This version adds a "twist": it uses Perry Kaufman's Efficiency Ratio to calculate adaptive true range

See how this compares to ATR here:

ER-Adaptive ATR [Loxx]

**Mean Absolute Deviation**

The mean absolute deviation (MAD) is a measure of variability that indicates the average distance between observations and their mean. MAD uses the original units of the data, which simplifies interpretation. Larger values signify that the data points spread out further from the average. Conversely, lower values correspond to data points bunching closer to it. The mean absolute deviation is also known as the mean deviation and average absolute deviation.

This definition of the mean absolute deviation sounds similar to the standard deviation (SD). While both measure variability, they have different calculations. In recent years, some proponents of MAD have suggested that it replace the SD as the primary measure because it is a simpler concept that better fits real life.

For Pine Coders, this is equivalent of using ta.dev()

**Bands/Channels**

See the information above for how bands/channels are calculated. After the one of the above deviations is calculated, the channels are calculated as output +/- deviation * multiplier

**Signals**

Green is uptrend, red is downtrend, yellow "L" signal is Long, fuchsia "S" signal is short.

**Included:**

**Related indicators**

*3-Pole Super Smoother w/ EMA-Deviation-Corrected Stepping [Loxx]*

*STD-Stepped Fast Cosine Transform Moving Average [Loxx]*

*ATR-Stepped PDF MA [Loxx] *

Due to the coding required to adapt a moving average to fit into this indicator, additional moving average types will be added as they are created to fit into this unique use case. Since this is a work in process, there will be many future updates of this indicator. For now, you can choose from either EMA or RMA.

This indicator is also considered one of the top 10 forex indicators. See details here: https://forex-station.com/viewtopic.php?t=8473244

Additionally, this indicator is a computationally faster, more streamlined version of the following indicators with the addition of 6 stepping functions and 6 different bands/channels types.

STD-Stepped, Variety N-Tuple Moving Averages [Loxx]

STD-Stepped, Variety N-Tuple Moving Averages is the standard deviation stepped/filtered indicator of the following indicator

Last but not least, a big shoutout to lejmer for his help in formulating a looping solution for this streamlined version. this indicator is speedy even at 50 orders deep. You can find his scripts here: https://www.tradingview.com/u/lejmer/#published-scripts

Step 1: Run factorial calculation on the depth value,

Step 2: Calculate weights of nested moving averages

factorial(depth) / (factorial(depth - k) * factorial(k); where depth is the depth and k is the weight position

Examples of coefficient outputs:

6 Depth: 6 15 20 15 6

7 Depth: 7 21 35 35 21 7

8 Depth: 8 28 56 70 56 28 8

9 Depth: 9 36 34 84 126 126 84 36 9

10 Depth: 10 45 120 210 252 210 120 45 10

11 Depth: 11 55 165 330 462 462 330 165 55 11

12 Depth: 12 66 220 495 792 924 792 495 220 66 12

13 Depth: 13 78 286 715 1287 1716 1716 1287 715 286 78 13

Step 3: Apply coefficient to each moving average

For QEMA, which is 5 depth EMA , the calculation is as follows

ema1 = ta. ema ( src , length)

ema2 = ta. ema (ema1, length)

ema3 = ta. ema (ema2, length)

ema4 = ta. ema (ema3, length)

ema5 = ta. ema (ema4, length)

In this new streamlined version, these MA calculations are packed into an array inside loop so Pine doesn't have to keep all possible series information in memory. This is handled with the following code:

temp = array.get(workarr, k + 1) + alpha * (array.get(workarr, k) - array.get(workarr, k + 1))

array.set(workarr, k + 1, temp)

After we pack the array, we apply the coefficients to derive the NTMA:

qema = 5 * ema1 - 10 * ema2 + 10 * ema3 - 5 * ema4 + ema5

First off, you can filter by both price and/or MA output. Both price and MA output can be filtered/stepped in their own way. You'll see two selectors in the input settings. Default is ATR ATR. Here's how stepping works in simple terms: if the price/MA output doesn't move by X deviations, then revert to the price/MA output one bar back.

The average true range (ATR) is a technical analysis indicator, introduced by market technician J. Welles Wilder Jr. in his book New Concepts in Technical Trading Systems, that measures market volatility by decomposing the entire range of an asset price for that period.

Standard deviation is a statistic that measures the dispersion of a dataset relative to its mean and is calculated as the square root of the variance. The standard deviation is calculated as the square root of variance by determining each data point's deviation relative to the mean. If the data points are further from the mean, there is a higher deviation within the data set; thus, the more spread out the data, the higher the standard deviation.

By definition, the Standard Deviation (STD, also represented by the Greek letter sigma σ or the Latin letter s) is a measure that is used to quantify the amount of variation or dispersion of a set of data values. In technical analysis we usually use it to measure the level of current volatility .

Standard Deviation is based on Simple Moving Average calculation for mean value. This version of standard deviation uses the properties of EMA to calculate what can be called a new type of deviation, and since it is based on EMA , we can call it EMA deviation. And added to that, Perry Kaufman's efficiency ratio is used to make it adaptive (since all EMA type calculations are nearly perfect for adapting).

The difference when compared to standard is significant--not just because of EMA usage, but the efficiency ratio makes it a "bit more logical" in very volatile market conditions.

See how this compares to Standard Devaition here:

Adaptive Deviation

The median absolute deviation is a measure of statistical dispersion. Moreover, the MAD is a robust statistic, being more resilient to outliers in a data set than the standard deviation. In the standard deviation, the distances from the mean are squared, so large deviations are weighted more heavily, and thus outliers can heavily influence it. In the MAD, the deviations of a small number of outliers are irrelevant.

Because the MAD is a more robust estimator of scale than the sample variance or standard deviation, it works better with distributions without a mean or variance, such as the Cauchy distribution.

For this indicator, I used a manual recreation of the quantile function in Pine Script. This is so users have a full inside view into how this is calculated.

Average True Range (ATR) is widely used indicator in many occasions for technical analysis . It is calculated as the RMA of true range. This version adds a "twist": it uses Perry Kaufman's Efficiency Ratio to calculate adaptive true range

See how this compares to ATR here:

ER-Adaptive ATR [Loxx]

The mean absolute deviation (MAD) is a measure of variability that indicates the average distance between observations and their mean. MAD uses the original units of the data, which simplifies interpretation. Larger values signify that the data points spread out further from the average. Conversely, lower values correspond to data points bunching closer to it. The mean absolute deviation is also known as the mean deviation and average absolute deviation.

This definition of the mean absolute deviation sounds similar to the standard deviation (SD). While both measure variability, they have different calculations. In recent years, some proponents of MAD have suggested that it replace the SD as the primary measure because it is a simpler concept that better fits real life.

For Pine Coders, this is equivalent of using ta.dev()

See the information above for how bands/channels are calculated. After the one of the above deviations is calculated, the channels are calculated as output +/- deviation * multiplier

Green is uptrend, red is downtrend, yellow "L" signal is Long, fuchsia "S" signal is short.

- Alerts
- Loxx's Expanded Source Types
- Bar coloring
- Signals
- 6 bands/channels types
- 6 stepping types

진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

Public Telegram Group, t.me/algxtrading_public

VIP Membership Info: patreon.com/algxtrading/membership

VIP Membership Info: patreon.com/algxtrading/membership

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.