Dickinson Moving Average (DMA)Implementation of the "Dickinson Moving Average" from the r/algotrading post by Nathan Dickinson
Quoted from the author of the Dickinson Moving Average:
"I was experimenting with the “zero lag” code from John Ehlers and the Hull Moving Average and noticed that they seemed to respond in complementary ways when properly set up. With the right starting values, they blend together to make a moving average which responds with one (or maybe even half a bar) of lag. To my eye, it looks to be almost as good as the Jurik Moving Average."
Optional parameter input available to use Exponential Hull Moving Average (EHMA) instead of WMA for the Hull MA is available.
Acknowledgements/Credits:
Nathan Dickinson, Dickinson Moving Average
@RicardoSantos, Function for Hull Moving Average
Exponential Hull Moving Average sourced from:
// Raudys, Aistis & Lenčiauskas, Vaidotas & Malčius, Edmundas. (2013). Moving Averages for Financial Data Smoothing.
// Communications in Computer and Information Science. 403. 34-45. 10.1007/978-3-642-41947-8_4.
@Everget, Jurik Moving Average
Jurik
General Filter Estimator-An Experiment on Estimating EverythingIntroduction
The last indicators i posted where about estimating the least squares moving average, the task of estimating a filter is a funny one because its always a challenge and it require to be really creative. After the last publication of the 1LC-LSMA , who estimate the lsma with 1 line of code and only 3 functions i felt like i could maybe make something more flexible and less complex with the ability to approximate any filter output. Its possible, but the methods to do so are not something that pinescript can do, we have to use another base for our estimation using coefficients, so i inspired myself from the alpha-beta filter and i started writing the code.
Calculation and The Estimation Coefficients
Simplicity is the key word, its also my signature style, if i want something good it should be simple enough, so my code look like that :
p = length/beta
a = close - nz(b ,close)
b = nz(b ,close) + a/p*gamma
3 line, 2 function, its a good start, we could put everything in one line of code but its easier to see it this way. length control the smoothing amount of the filter, for any filter f(Period) Period should be equal to length and f(Period) = p , it would be inconvenient to have to use a different length period than the one used in the filter we want to estimate (imagine our estimation with length = 50 estimating an ema with period = 100) , this is where the first coefficients beta will be useful, it will allow us to leave length as it is. In general beta will be greater than 1, the greater it will be the less lag the filter will have, this coefficient will be useful to estimate low lagging filters, gamma however is the coefficient who will estimate lagging filters, in general it will range around .
We can get loose easily with those coefficients estimation but i will leave a coefficients table in the code for estimating popular filters, and some comparison below.
Estimating a Simple Moving Average
Of course, the boxcar filter, the running mean, the simple moving average, its an easy filter to use and calculate.
For an SMA use the following coefficients :
beta = 2
gamma = 0.5
Our filter is in red and the moving average in white with both length at 50 (This goes for every comparison we will do)
Its a bit imprecise but its a simple moving average, not the most interesting thing to estimate.
Estimating an Exponential Moving Average
The ema is a great filter because its length times more computing efficient than a simple moving average. For the EMA use the following coefficients :
beta = 3
gamma = 0.4
N.B : The EMA is rougher than the SMA, so it filter less, this is why its faster and closer to the price
Estimating The Hull Moving Average
Its a good filter for technical analysis with tons of use, lets try to estimate it ! For the HMA use the following coefficients :
beta = 4
gamma = 0.85
Looks ok, of course if you find better coefficients i will test them and actualize the coefficient table, i will also put a thank message.
Estimating a LSMA
Of course i was gonna estimate it, but this time this estimation does not have anything a lsma have, no moving average, no standard deviation, no correlation coefficient, lets do it.
For the LSMA use the following coefficients :
beta = 3.5
gamma = 0.9
Its far from being the best estimation, but its more efficient than any other i previously made.
Estimating the Quadratic Least Square Moving Average
I doubted about this one but it can be approximated as well. For the QLSMA use the following coefficients :
beta = 5.25
gamma = 1
Another ok estimate, the estimate filter a bit more than needed but its ok.
Jurik Moving Average
Its far from being a filter that i like and its a bit old. For the comparison i will use the JMA provided by @everget described in this article : c.mql5.com
For the JMA use the following coefficients :
for phase = 0
beta = pow*2 (pow is a parameter in the Jma)
gamma = 0.5
Here length = 50, phase = 0, pow = 5 so beta = 10
Looks pretty good considering the fact that the Jma use an adaptive architecture.
Discussion
I let you the task to judge if the estimation is good or not, my motivation was to estimate such filters using the less amount of calculations as possible, in itself i think that the code is quite elegant like all the codes of IIR filters (IIR Filters = Infinite Impulse Response : Filters using recursion) .
It could be possible to have a better estimate of the coefficients using optimization methods like the gradient descent. This is not feasible in pinescript but i could think about it using python or R.
Coefficients should be dependant of length but this would lead to a massive work, the variation of the estimation using fixed coefficients when using different length periods is just ok if we can allow some errors of precision.
I dont think it should be possible to estimate adaptive filter relying a lot on their adaptive parameter/smoothing constant except by making our coefficients adaptive (gamma could be)
So at the end ? What make a filter truly unique ? From my point of sight the architecture of a filter and the problem he is trying to solve is what make him unique rather than its output result. If you become a signal, hide yourself into noise, then look at the filters trying to find you, what a challenging game, this is why we need filters.
Conclusion
I wanted to give a simple filter estimator relying on two coefficients in order to estimate both lagging and low-lagging filters. I will try to give more precise estimate and update the indicator with new coefficients.
Thanks for reading !
Jurik RSX on JMAThis is Jurik RSX version that accepts price preliminarily filtered using the best original JMA' clone on TradingView .
As Mr. Jurik noticed:
"A smooth (low noise) trend is more efficient than a noisy trend. Given that RSX measures market trend direction and efficiency, it stands to reason that RSX would respond better (display larger dynamic range) when fed pre-smoothed price data. And there's no better way to pre-smooth than by using JMA " .
And as the result: "it reverses with the market, showing almost no lag" .
Jurik's RSX is a "noise free" version of RSI, with no added lag.
Reference:
www.jurikres.com
www.jurikres.com
Jurik JMA/DWMA MACDAn oscillator form of the crossover system that was recommended by Mark Jurik. The oscillator is based on the Jurik Moving Average (JMA) and Double Weighted Moving Average (DWMA) convergence/divergence. I use the best original JMA' clone on TradingView that has the almost identical behaviour as the original one.
I made it more pretty and added alerts for the peaks (blue circles).
As Mr. Jurik noticed:
"Of all the different combinations of moving average filters to use for a MACD oscillator, we prefer using the JMA - DWMA combination."
Reference: www.jurikres.com
Jurik JMA/DWMA CrossoverThis is a crossover system that was recommended by Mark Jurik. The system consists of Jurik Moving Average (JMA) and Double Weighted Moving Average (DWMA). In case of Jurik Moving Average I use the best original JMA' clone on TradingView that has the almost identical behaviour as the original one.
As Mr. Jurik noticed:
" JMA is ideal for the fast moving average line because it is quick to respond to reversals, is smooth and can be set to have no overshoot. DWMA (double weighted moving average) is ideal for the slower line as is tends to delay reversing direction until JMA crosses it."
Reference: www.jurikres.com
Profitable Moving Average CrossoverHi everyone!
Introduction
A popular use for moving averages is to develop simple trading systems based on moving average crossovers. A trading system using two moving averages would give a buy signal when the shorter (faster) moving average advances above the longer (slower) moving average. A sell signal would be given when the shorter moving average crosses below the longer moving average. The speed of the systems and the number of signals generated will depend on the length of the moving averages.
There are many types of averages that are based on different techniques. Each type has its drawbacks and merits. And if we decide to choose a certain type of average for the trading system, then how do we know that our choice is optimal?
What is this tool?
This tool will help you to choose this type to create the most profitable trading system based on crossovers for the specified periods. It backtests pairs of each type throughout the whole instrument's history and shows Net Profit curves as a result. So, the type of the most profitable crossover system will be at the top of list of labels on the chart. (Click on the price scale, point to "Labels" and switch off "No Overlapping Labels" option).
Settings
The main settings are periods for each type pair of fast and slow moving averages.
Additionally, it allows to customize some multi-parametric moving averages such as JMA, ALMA, McGinley Dynamic, Adaptive Laguerre Filter etc.
1st Period (default: 14 )
2nd Period (default: 50 )
1st ALF Median Length (default: 5 )
2nd ALF Median Length (default: 5 )
1st ALMA Offset (default: 0.85 )
1st ALMA Sigma (default: 6 )
2nd ALMA Offset (default: 0.85 )
2nd ALMA Sigma (default: 6 )
1st HF Scaling Factor (default: 3 )
2nd HF Scaling Factor (default: 3 )
1st JMA Phase (default: 50 )
2nd JMA Phase (default: 50 )
1st MD Constant (default: 0.6 )
2nd MD Constant (default: 0.6 )
1st MHLMA Range (default: 10 )
2nd MHLMA Range (default: 10 )
1st PWMA Power (default: 2 )
2nd PWMA Power (default: 2 )
1st REMA Lambda (default: 0.5 )
2nd REMA Lambda (default: 0.5 )
1st RMF Median Length (default: 5 )
2nd RMF Median Length (default: 5 )
1st T3 Alpha (default: 0.7 )
2nd T3 Alpha (default: 0.7 )
MAMA & FAMA Fast Limit (default: 0.5 )
MAMA & FAMA Slow Limit (default: 0.05 )
Supported types of averages and filters (use short titles to match averages on the chart)
AHMA , Ahrens MA (by Richard D. Ahrens)
ALMA , Arnaud Legoux MA (by Arnaud Legoux and Dimitris Kouzis-Loukas)
ALF , Adaptive Laguerre Filter (by John F. Ehlers)
ARSI , Adaptive RSI
BF2 , Butterworth Filter with 2 poles
BF3 , Butterworth Filter with 3 poles
DEMA , Double Exponential MA (by Patrick G. Mulloy)
DWMA , Double Weighted (Linear) MA
EDCF , Ehlers Distance Coefficient Filter (by John F. Ehlers)
EHMA , Exponential Hull MA
EMA , Exponential MA
EVWMA , Elastic Volume Weighted MA (by Christian P. Fries)
FRAMA , Fractal Adaptive MA (by John F. Ehlers)
GF1 , Gaussian Filter with 1 pole
GF2 , Gaussian Filter with 2 poles
GF3 , Gaussian Filter with 3 poles
GF4 , Gaussian Filter with 4 poles
HFSMA , Hampel Filter on Simple Moving Average
HFEMA , Hampel Filter on Exponential Moving Average
HMA , Hull MA (by Alan Hull)
HWMA , Henderson Weighted MA (by Robert Henderson)
IDWMA , Inverse Distance Weighted MA
IIRF , Infinite Impulse Response Filter (by John F. Ehlers)
JMA , Jurik MA (by Mark Jurik, )
LF , Laguerre Filter (by John F. Ehlers)
LMA , Leo MA (by ProRealCode' user Leo)
LSMA , Least Squares MA (Moving Linear Regression)
MAMA & FAMA , (by John F. Ehlers, special case that used as a benchmark)
MD , McGinley Dynamic (by John R. McGinley)
MHLMA , Middle-High-Low MA (by Vitali Apirine)
PWMA , Parabolic Weighted MA
REMA , Regularized Exponential MA (by Chris Satchwell)
RMA , Running MA (by J. Welles Wilder)
RMF , Recursive Median Filter (by John F. Ehlers)
RMTA , Recursive Moving Trend Average (by Dennis Meyers)
SHMMA , Sharp Modified MA (by Joe Sharp)
SMA , Simple MA
SSF2 , Super Smoother Filter with 2 poles (by John F. Ehlers)
SSF3 , Super Smoother Filter with 3 poles (by John F. Ehlers)
SWMA , Sine Weighted MA
TEMA , Triple Exponential MA (by Patrick G. Mulloy)
TMA , Triangular MA (generalized by John F. Ehlers)
T3 , (by Tim Tillson)
VIDYA , Variable Index Dynamic Average (by Tushar S. Chande)
VWMA , Volume Weighted MA (by Buff P. Dormeier)
WMA , Weighted (Linear) MA
ZLEMA , Zero Lag Exponential MA (by John F. Ehlers and Ric Way)
NOTE : The results may vary on different tickers and timeframes.
If you see the preview result it doesn't mean that these crossovers will be profitable on other instruments and timeframes. This is a normal situation because time series and their characteristics differ.
I know that because I tested this tool before publishing.
NOTE 2 : You can use this tool by yourself and experiment with it, or you can order a study and I will share the spreadsheet that contains results with you.
Good luck!
Jurik Moving AverageThis is my best attempt to reproduce the original Jurik Moving Average. It differs from Jurik's a little bit, but in most cases it behaves like the original.
Jurik Moving Average is known as a superior noise elimination (causal, nonlinear and adaptive) filter and a world class moving average that tracks and smoothes price charts or any market-related time series with surprising agility.
Settings
Length (default: 7 )
Phase (default: 50 )
Price Source (default: close )
I attached some screenshots to show you how it works with other instruments
USDJPY, D
USDJPY, 60
USDCAD, D
USDCHF, D
EURUSD, D
GBPJPY, D
AUDUSD, D
XAUUSD, D
XAUUSD, 60
AAPL, D
AAPL, 60
MSFT, D
AMZN, D
BTCUSD, D
BTCUSD, 60
ETHUSD, D
Good luck and happy trading!
Jurik RSXAdopted to Pine from www.prorealcode.com .
I haven't yet understood the details of the algorithm but it matches the original Jurik's RSX one to one.
Jurik's RSX is a "noise free" version of RSI, with no added lag. To learn more about this indicator see www.jurikres.com .
Good luck!
Moving Average Smoothness BenchmarkHey there!
This tool will help you to choose a moving average/filter that has the lowest lag throughout the whole history for the specified period.
What does it do?
It calculates the mean absolute errors for each moving average or filter and shows histogram with results. The lower error the lower lag of the moving average.
So, the best average will be at the end of the list of labels on the chart.
Settings
The main setting is a period for all moving averages.
Additionally, it allows to customize some multi-parametric moving average such as JMA, ALMA, McGinley Dynamic, Tillson's T3, REMA, Adaptive Laguerre Filter, Hampel Filter, Recursive Median Filter and Middle-High-Low MA.
NOTE : The results may vary on the different tickers and timeframes. This tool measures the performances on the current ticker and on the current timeframe.
Supported averages/filters (use short titles to match movings on the chart)
SMA, Simple MA
EMA, Exponential MA
WMA, Weighted (Linear) MA
RMA, Running MA (by J. Welles Wilder)
VWMA, Volume Weighted MA (by Buff P. Dormeier)
AHMA, Ahrens MA (by Richard D. Ahrens)
ALMA, Arnaud Legoux MA (by Arnaud Legoux and Dimitris Kouzis-Loukas)
ALF, Adaptive Laguerre Filter (by John F. Ehlers)
ARSI, Adaptive RSI
DEMA, Double Exponential MA (by Patrick G. Mulloy)
EDCF, Ehlers Distance Coefficient Filter (by John F. Ehlers)
EVWMA, Elastic Volume Weighted MA (by Christian P. Fries)
FRAMA, Fractal Adaptive MA (by John F. Ehlers)
HFSMA, Hampel Filter on Simple Moving Average
HFEMA, Hampel Filter on Exponential Moving Average
HMA, Hull MA (by Alan Hull)
HWMA, Henderson Weighted MA (by Robert Henderson)
IIRF, Infinite Impulse Response Filter (by John F. Ehlers)
JMA1, Jurik MA with power of 1 (by Mark Jurik)
JMA2, Jurik MA with power of 2 (by Mark Jurik)
JMA3, Jurik MA with power of 3 (by Mark Jurik)
JMA4, Jurik MA with power of 4 (by Mark Jurik)
LF, Laguerre Filter (by John F. Ehlers)
LMA, Leo MA (by ProRealCode' user Leo)
LSMA, Least Squares MA (Moving Linear Regression)
MD, McGinley Dynamic (by John R. McGinley)
MHLMA, Middle-High-Low MA (by Vitali Apirine)
REMA, Regularized Exponential MA (by Chris Satchwell)
RMF, Recursive Median Filter (by John F. Ehlers)
RMTA, Recursive Moving Trend Average (by Dennis Meyers)
SHMMA, Sharp Modified MA (by Joe Sharp)
SWMA, Sine Weighted MA
TEMA, Triple Exponential MA (by Patrick G. Mulloy)
TMA, Triangular MA
T3, (by Tim Tillson)
VIDYA, Variable Index Dynamic Average (by Tushar S. Chande)
ZLEMA, Zero Lag Exponential MA (by John F. Ehlers and Ric Way)
BF2, Butterworth Filter with 2 poles
BF3, Butterworth Filter with 3 poles
SSF2, Super Smoother Filter with 2 poles (by John F. Ehlers)
SSF3, Super Smoother Filter with 3 poles (by John F. Ehlers)
GF1, Gaussian Filter with 1 pole
GF2, Gaussian Filter with 2 poles
GF3, Gaussian Filter with 3 poles
GF4, Gaussian Filter with 4 poles
Good luck and Merry Christmas!
Jurik Moving AverageThis indicator was originally developed by Mark Jurik.
NOTE: If Mr. Jurik ask me to remove this indicator from public access then I will do it.
JMA Clone 3The clone of Jurik moving average function with a power argument
The power argument allows to closely approximate price movements. The higher the power, the closer the fit. Also helps to find a balance between smoothing and fitting.