# ALMA (Arnaud Legoux MA) Indicator for ThinkorSwim

#### Miket

##### Member
Hello All, here is my contribution to the blog as I don't believe in taking without giving back. I hope someone can find as useful as I have.

The goal of the Arnaud Legoux Average is to decrease the noise and generate a more reliable signal than the conventional moving averages.

It does this by applying the average from left to right (the usual way), and then it applies the reverse and makes a combo line. This combo signal is then adjusted by applying a Gaussian Offset that can adjust the combo line to the current price and a sigma (standard deviation).

### thinkScript Code

Rich (BB code):
``````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();``````

https://tos.mx/9mznij

Last edited by a moderator:
@Miket Thanks for sharing. I renamed the title of the post and also included the source code just in case anyone want to take a sneak peak at it before adding.

Last edited:
@Miket, Thanks for sharing this indicator and this is something different than EMA. Do you suggest any other indicator which we can combine with this.

Last edited:
I get a lot of value using the ALMA, however I can not locate any scans which would employ 2 ALMA windows (look-back) values which could be adjusted by the user. I did not see the ALMA as a choice in the StockHacker scan menu. Does anyone know where I may find these scans?

@Lambert58 Put this on your chart or scan twice and adjust the input length. I hope this helps.
You'll have to consult the manual or another code to get numbers in your scan.

Code:
``````# ArnaudLegouxMA_Mobius
##with color change  below##
# ALMA (Arnaud Legoux Moving Average)
# ALMA is based on a shifted Gaussian distribution
# Mobius
# Chat Room Request No Date (2017 - 2019)
## ALMA color change added by ZupDog

input offset = 2;
input sigma = .5;
input length = 8;
plot alma_ = (fold n = 0 to length
with s
do s + getValue(Exp(-Power(n - Floor(offset * length), 2)/
(2 * Power((length + 1) / sigma, 2)))*
getValue(close, n), n, length)) /
fold nn = 0 to length
with ss
do ss + getValue(Exp(-Power(nn - Floor(offset * length), 2)/
(2 * Power((length + 1) / sigma, 2))), nn);
alma_.DefineColor("Up", GetColor(1));
alma_.DefineColor("Down", GetColor(0));
alma_.AssignValueColor(if alma_ > alma_[1] then alma_.color("Up") else alma_.color("Down"));
# End Code ALMA``````

@Miket, Thanks for sharing this indicator and this is something different than EMA. Do you suggest any other indicator which we can combine with this.
@San This suggestion may help: Take a blank chart and put each type of MA in an upper, set them all to the same length, and see how they react on different time frames. It's a fun learning exercise.

@San This suggestion may help: Take a blank chart and put each type of MA in an upper, set them all to the same length, and see how they react on different time frames. It's a fun learning exercise.
@markos, Hey thanks for your suggestion.... I will start practicing... I am slowly getting it... I really appreciate you and forum for quick response.

I've tested this ALMA against the Ehlers Super Smoother Filter that is found in TOS...and the Ehlers works better primarily because you can use the variations of Ehlers in other Moving average forms like the 20 50 100 200 etc...You just need to multiply the regular known MA by .58 to get the Ehlers equivalent...For example such as 20 MA x .58 = 11.6 Then add 20 + 11.6 and you'll get the equivalent to I believe weighted MA but with super smooth curves...hope this helps

Thanks for everyone's input and offering their experience. The real diamond is when I tracked down a tiny thread which led me to find all of you at this community.

@Lambert58 Welcome. There are many Moving average variations. Most times by changing inputs you can get them to match each other. Just pick one you like and go with it.

Thanks for sharing. can you help to understand on how to use this please?

My interpretation is to use which ever MovAvg you choose, in the example above it was 20 MA X.58 = 11.6. Add(11.6) to 20 = 31.6 or 32. This would be the value for the Ehlers equivalent. The smoothing of the MA curve helps to avoid whipsaws. I am learning, so in the event my interpretation is not correct, standby, someone will more experience will usually clarify.

My interpretation is to use which ever MovAvg you choose, in the example above it was 20 MA X.58 = 11.6. Add(11.6) to 20 = 31.6 or 32. This would be the value for the Ehlers equivalent. The smoothing of the MA curve helps to avoid whipsaws. I am learning, so in the event my interpretation is not correct, standby, someone will more experience will usually clarify.

@Lambert58 The example I referenced above was for Ehlers Super Smoother Filter that is found in TOS. If you compare both ALMA and the default setting of SuperSmootherFilter that is set to 10 you will see that they are practically identical. The reason why I like Ehlers better is that you can get other averages like the 20 50 etc...all you have to do is X .58 and add on to the original moving average as you stated above...

By doing such a conversion I believe that the Ehlers Super Smoother Filter will reflect the same as a standard WMA of 20 50 etc...but with much smoother lines and curves.

I'm trying to scan for stocks where the Close is greater than ALMA (50, 6. 0.85) and it keeps coming up with zero matching symbols even though I am looking at charts where this is the case. In fact, I cannot get the scan to work for any close > ALMA (x, 6, 0.85). Am I missing something? Thanks, all.

I'm trying to scan for stocks where the Close is greater than ALMA (50, 6. 0.85) and it keeps coming up with zero matching symbols even though I am looking at charts where this is the case. In fact, I cannot get the scan to work for any close > ALMA (x, 6, 0.85). Am I missing something? Thanks, all.
Is this the case with all timeframes...???

Is this the case with all timeframes...???
it is, unfortunately. Very strange.

No luck, eh? Guessing it's something to do with the way the thinkscript is coded. It starts with the code embedded within a 'script' function and then includes the same plot a 2nd time later. Keep us posted...

@Miket thanks for this! I've compared this one with the other Alma I was using and it's tighter and smoother. I already see some of my 1HR charts change color and cross the middle Donchian channel line one candle earlier on the bull and bear side. Which is something I look for when I go long and short. thanks again!

hi is there a scanner for this ALMA study when price crosses ALMA @BenTen

@wesam There is a problem with using the scanner with this indicator. As explained in this thread starting with post#17.

87k+ Posts
273 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?