Library "MovingAveragesProxy" Moving Averages Proxy - Library of all moving averages spread out in different libraries
rvwap(_src, fixedTfInput, minsInput, hoursInput, daysInput, minBarsInput) Calculates the Rolling VWAP (customized VWAP developed by the team of TradingView) Parameters: _src: (float) Source. Default: close fixedTfInput: (bool) Use a fixed time period. Default: false minsInput: (int) Minutes. Default: 0 hoursInput: (int) Hours. Default: 0 daysInput: (int) Days. Default: 1 minBarsInput: (int) Bars. Default: 10 Returns: (float) Rolling VWAP
correlationMa(src, len, factor) Correlation Moving Average Parameters: src: (float) Source. Default: close len: (int) Length factor: (float) Factor. Default: 1.7 Returns: (float) Correlation Moving Average
regma(src, len, lambda) Regularized Exponential Moving Average Parameters: src: (float) Source. Default: close len: (int) Length lambda: (float) Lambda. Default: 0.5 Returns: (float) Regularized Exponential Moving Average
repma(src, len) Repulsion Moving Average Parameters: src: (float) Source. Default: close len: (int) Length Returns: (float) Repulsion Moving Average
epma(src, length, offset) End Point Moving Average Parameters: src: (float) Source. Default: close length: (int) Length offset: (float) Offset. Default: 4 Returns: (float) End Point Moving Average
lc_lsma(src, length) 1LC-LSMA (1 line code lsma with 3 functions) Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) 1LC-LSMA Moving Average
aarma(src, length) Adaptive Autonomous Recursive Moving Average Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Adaptive Autonomous Recursive Moving Average
alsma(src, length) Adaptive Least Squares Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Adaptive Least Squares
ahma(src, length) Ahrens Moving Average Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Ahrens Moving Average
adema(src) Ahrens Moving Average Parameters: src: (float) Source. Default: close Returns: (float) Moving Average
autol(src, lenDev) Auto-Line Parameters: src: (float) Source. Default: close lenDev: (int) Length for standard deviation Returns: (float) Auto-Line
fibowma(src, length) Fibonacci Weighted Moving Average Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Moving Average
fisherlsma(src, length) Fisher Least Squares Moving Average Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Moving Average
leoma(src, length) Leo Moving Average Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Moving Average
linwma(src, period, weight) Linear Weighted Moving Average Parameters: src: (float) Source. Default: close period: (int) Length weight: (int) Weight Returns: (float) Moving Average
mcma(src, length) McNicholl Moving Average Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Moving Average
srwma(src, length) Square Root Weighted Moving Average Parameters: src: (float) Source. Default: close length: (int) Length Returns: (float) Moving Average
EDSMA(src, len) Ehlers Dynamic Smoothed Moving Average. Parameters: src: Series to use ('close' is used if no argument is supplied). len: Lookback length to use. Returns: EDSMA smoothing.
dema(x, t) Double Exponential Moving Average. Parameters: x: Series to use ('close' is used if no argument is supplied). t: Lookback length to use. Returns: DEMA smoothing.
tema(src, len) Triple Exponential Moving Average. Parameters: src: Series to use ('close' is used if no argument is supplied). len: Lookback length to use. Returns: TEMA smoothing.
smma(src, len) Smoothed Moving Average. Parameters: src: Series to use ('close' is used if no argument is supplied). len: Lookback length to use. Returns: SMMA smoothing.
hullma(src, len) Hull Moving Average. Parameters: src: Series to use ('close' is used if no argument is supplied). len: Lookback length to use. Returns: Hull smoothing.
frama(x, t) Fractal Reactive Moving Average. Parameters: x: Series to use ('close' is used if no argument is supplied). t: Lookback length to use. Returns: FRAMA smoothing.
kama(x, t) Kaufman's Adaptive Moving Average. Parameters: x: Series to use ('close' is used if no argument is supplied). t: Lookback length to use. Returns: KAMA smoothing.
vama(src, len) Volatility Adjusted Moving Average. Parameters: src: Series to use ('close' is used if no argument is supplied). len: Lookback length to use. Returns: VAMA smoothing.
donchian(len) Donchian Calculation. Parameters: len: Lookback length to use. Returns: Average of the highest price and the lowest price for the specified look-back period.
Jurik(src, len) Jurik Moving Average. Parameters: src: Series to use ('close' is used if no argument is supplied). len: Lookback length to use. Returns: JMA smoothing.
xema(src, len) Optimized Exponential Moving Average. Parameters: src: Series to use ('close' is used if no argument is supplied). len: Lookback length to use. Returns: XEMA smoothing.
ehma(src, len) EHMA - Exponential Hull Moving Average Parameters: src: Source len: Period Returns: Exponential Hull Moving Average (EHMA)
covwema(src, len) Coefficient of Variation Weighted Exponential Moving Average (COVWEMA) Parameters: src: Source len: Period Returns: Coefficient of Variation Weighted Exponential Moving Average (COVWEMA)
covwma(src, len) Coefficient of Variation Weighted Moving Average (COVWMA) Parameters: src: Source len: Period Returns: Coefficient of Variation Weighted Moving Average (COVWMA)
eframa(src, len, FC, SC) Ehlrs Modified Fractal Adaptive Moving Average (EFRAMA) Parameters: src: Source len: Period FC: Lower Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average SC: Upper Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average Returns: Ehlrs Modified Fractal Adaptive Moving Average (EFRAMA)
etma(src, len) Exponential Triangular Moving Average (ETMA) Parameters: src: Source len: Period Returns: Exponential Triangular Moving Average (ETMA)
rma(src, len) RMA - RSI Moving average Parameters: src: Source len: Period Returns: RSI Moving average (RMA)
thma(src, len) THMA - Triple Hull Moving Average Parameters: src: Source len: Period Returns: Triple Hull Moving Average (THMA)
vidya(src, len) Variable Index Dynamic Average (VIDYA) Parameters: src: Source len: Period Returns: Variable Index Dynamic Average (VIDYA)
zsma(src, len) Zero-Lag Simple Moving Average (ZSMA) Parameters: src: Source len: Period Returns: Zero-Lag Simple Moving Average (ZSMA)
zema(src, len) Zero-Lag Exponential Moving Average (ZEMA) Parameters: src: Source len: Period Returns: Zero-Lag Exponential Moving Average (ZEMA)
evwma(src, len) EVWMA - Elastic Volume Weighted Moving Average Parameters: src: Source len: Period Returns: Elastic Volume Weighted Moving Average (EVWMA)
tt3(src, len, a1_t3) Tillson T3 Parameters: src: Source len: Period a1_t3: Tillson T3 Volume Factor Returns: Tillson T3
gma(src, len) GMA - Geometric Moving Average Parameters: src: Source len: Period Returns: Geometric Moving Average (GMA)
wwma(src, len) WWMA - Welles Wilder Moving Average Parameters: src: Source len: Period Returns: Welles Wilder Moving Average (WWMA)
cma(src, len) Corrective Moving average (CMA) Parameters: src: Source len: Period Returns: Corrective Moving average (CMA)
edma(src, len) Exponentially Deviating Moving Average (MZ EDMA) Parameters: src: Source len: Period Returns: Exponentially Deviating Moving Average (MZ EDMA)
rema(src, len) Range EMA (REMA) Parameters: src: Source len: Period Returns: Range EMA (REMA)
sw_ma(src, len) Sine-Weighted Moving Average (SW-MA) Parameters: src: Source len: Period Returns: Sine-Weighted Moving Average (SW-MA)
mama(src, len) MAMA - MESA Adaptive Moving Average Parameters: src: Source len: Period Returns: MESA Adaptive Moving Average (MAMA)
fama(src, len) FAMA - Following Adaptive Moving Average Parameters: src: Source len: Period Returns: Following Adaptive Moving Average (FAMA)
hkama(src, len) HKAMA - Hilbert based Kaufman's Adaptive Moving Average Parameters: src: Source len: Period Returns: Hilbert based Kaufman's Adaptive Moving Average (HKAMA)
getMovingAverage(type, src, len, lsmaOffset, inputAlmaOffset, inputAlmaSigma, FC, SC, a1_t3, fixedTfInput, daysInput, hoursInput, minsInput, minBarsInput, lambda, volumeWeighted, gamma_aarma, smooth, linweight, volatility_lookback, jurik_phase, jurik_power) Abstract proxy function that invokes the calculation of a moving average according to type Parameters: type: (string) Type of moving average src: (float) Source of series (close, high, low, etc.) len: (int) Period of loopback to calculate the average lsmaOffset: (int) Offset for Least Squares MA inputAlmaOffset: (float) Offset for ALMA inputAlmaSigma: (float) Sigma for ALMA FC: (int) Lower Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average SC: (int) Upper Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average a1_t3: (float) Tillson T3 Volume Factor fixedTfInput: (bool) Use a fixed time period in Rolling VWAP daysInput: (int) Days in Rolling VWAP hoursInput: (int) Hours in Rolling VWAP minsInput: (int) Minutrs in Rolling VWAP minBarsInput: (int) Bars in Rolling VWAP lambda: (float) Regularization Constant in Regularized EMA volumeWeighted: (bool) Apply volume weighted calculation in selected moving average gamma_aarma: (float) Gamma for Adaptive Autonomous Recursive Moving Average smooth: (float) Smooth for Adaptive Least Squares linweight: (float) Weight for Volume Weighted Moving Average volatility_lookback: (int) Loopback for Volatility Adjusted Moving Average jurik_phase: (int) Phase for Jurik Moving Average jurik_power: (int) Power for Jurik Moving Average Returns: (float) Moving average
Release Notes
v2
Added: donchianHighLow(len, bands) Donchian Calculation with extra parameters. Originally, the average of the Donchian channel is obtained by adding the tops with the bottoms and dividing the value by 2. Here this divisor can be customized, not being limited to 2. Also, in this version the high is caught from the high and the low from low, rather than close Parameters: len: Lookback length to use. bands: Divisor. Default is 2. Returns: Average of the highest price and the lowest price for the specified look-back period.
Updated: getMovingAverage(type, src, len, lsmaOffset, inputAlmaOffset, inputAlmaSigma, FC, SC, a1_t3, fixedTfInput, daysInput, hoursInput, minsInput, minBarsInput, lambda, factor, offset_epma, volumeWeighted, gamma_aarma, smooth, linweight, volatility_lookback, jurik_phase, jurik_power, donchianBands) Abstract proxy function that invokes the calculation of a moving average according to type Parameters: type: (string) Type of moving average src: (float) Source of series (close, high, low, etc.) len: (int) Period of loopback to calculate the average lsmaOffset: (int) Offset for Least Squares MA inputAlmaOffset: (float) Offset for ALMA inputAlmaSigma: (float) Sigma for ALMA FC: (int) Lower Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average SC: (int) Upper Shift Limit for Ehlrs Modified Fractal Adaptive Moving Average a1_t3: (float) Tillson T3 Volume Factor fixedTfInput: (bool) Use a fixed time period in Rolling VWAP daysInput: (int) Days in Rolling VWAP hoursInput: (int) Hours in Rolling VWAP minsInput: (int) Minutrs in Rolling VWAP minBarsInput: (int) Bars in Rolling VWAP lambda: (float) Regularization Constant in Regularized EMA factor offset_epma volumeWeighted: (bool) Apply volume weighted calculation in selected moving average gamma_aarma: (float) Gamma for Adaptive Autonomous Recursive Moving Average smooth: (float) Smooth for Adaptive Least Squares linweight: (float) Weight for Volume Weighted Moving Average volatility_lookback: (int) Loopback for Volatility Adjusted Moving Average jurik_phase: (int) Phase for Jurik Moving Average jurik_power: (int) Power for Jurik Moving Average donchianBands Returns: (float) Moving average
Release Notes
v3 New parameter for VWAP: anchor (bool): (bool) The condition that triggers the reset of VWAP calculations. When true, calculations reset; when false, calculations proceed using the values accumulated since the previous reset. Optional. The default is equivalent to passing timeframe.change with "1D" as its argument.
Release Notes
v4 Code refactored to improve performance. The improvement in speed can be as much as 50% or more.
So now, to identify the type of moving average, the getMovingAverage function accepts a number (key) corresponding to each type.
The table of keys is in the comment at the beginning of the source code.
The obvious reason is that the integer data type takes up less memory than the string type.
In addition, the getMovingAverageVolume function was created, which works exactly like getMovingAverage, except that it uses the volume (when applicable).
This reduced the number of IFs, reducing the processing required for each situation.
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.