The research for the perfect Moving Average is a constant in the trading world. A moving average can be used to alert of trend changes, market overbought/oversold conditions or “unnormal” values. Having the perfect balance between precision and smoothness in a moving average has been the goal of numerous studies and projects, giving birth to a variaety of moving averages like Simple Moving Average (SMA), Exponential MA (EMA), Weighted MA (WMA), Wilder MA, Hull MA (HMA), Jurik MA (JMA), Fractal Adaptive MA (FAMA), MESA Adaptive MA (MAMA), etc.
Among them, there is one that it is specially famous, the Arnaud Legoux MA (ALMA), and for good reasons. ALMA doesn’t give too much importance to what happened in the very last bar of data, but to the underlying trend. It responds quick to changes in trend and doesn’t suffer from any overshoot effects found in others MA like HMA.
Not happy with all of this, ALMA is available for free on the Internet. Other MAs are behind high paying walls that not everyone are willing to jump. Thanks to this, ALMA has been downloaded more than 25,000 times since January 2010, and counting.
But! There is no ThinkOrSwim code available in the ALMA website, there is no ALMA indicator in ThinkOrSwim, and, until today, I haven’t found anyone on the Internet that has published the ALMA adapted to ThinkOrSwim language, ThinkScript.
Thanks to someone adapting ALMA to Excel, I’ve been able to adapt ALMA to ThinkOrSwim and I’m recoding all my old indicators to use ALMA as their MA. This will result in better signals for all of those indicators that try to highlight out-of-the-normal values.
As ALMA is shared for free on the Internet by its original authors, I want to join them and offer for free the ThinkScript code for ALMA:
Code:
#XBPTrading: http://xbptrading.com | xbptrading@gmail.com
#XBP18_01_ALMA
#Update: August 2017
script ALMA {
input Data = close;
input Window = 9;
input Sigma = 6;
input Offset = 0.85;
def m = (Offset * (Window - 1));
def s = Window/Sigma;
def SumVectorData = fold y = 0 to Window with WS do WS + Exp(-(sqr(y-m))/(2*sqr(s))) * getvalue(Data, (Window-1)-y);
def SumVector = fold z = 0 to Window with CW do CW + Exp(-(sqr(z-m))/(2*sqr(s)));
plot ALMA = SumVectorData / SumVector;
}
input Window = 9;
input Sigma = 6;
input Offset = 0.85;
plot ALMA = ALMA (close, Window, Sigma, Offset);
ALMA.setPaintingStrategy(PaintingStrategy.LINE);
ALMA.SetDefaultColor(Color.CYAN);
ALMA.HideTitle();
ALMA.HideBubble();
Note: If you use this code in your indicators, please keep the 3 commented lines in the header.
As an example here is Nasdaq futures with ALMA(9, 6, 0.85):
I have a moving average that seems to follow ALMA exactly… let me know if u want to know more
LikeLike
Hi Brian. Sorry for the late reply. Yes! Of course I want to know more. Please send me an email or let me know how to contact you.
LikeLike
Thanks for the links to a spreadsheet version. Yours was the only Excel link I found. Seems to work well in Excel. I was looking at ALMA versus Jurick Research JMA in a tradingview.com chart and they are very similar in speed, smoothness, and overshoot (or lack of) with the right settings. I do not believe that Jurick Research provides JMA for Excel currently so ALMA is an excellent free replacement.
LikeLike