Double Smoothed Momenta For ThinkOrSwim


Well-known member
Hello, does anyone in the useThinkscript community have any experience, good or bad, which they care to share regarding William Blau's Double Smoothed Momenta (not a typo) strategy, and/or access to a TradingView translation of the approach as described here? William Blau does some interesting stuff and I wish I had studied his stuff sooner. Thank you!

here is my conversion of the pine study

# convert_momenta_smoothes_00

#Tradingview Convert Tradingview Double Smoothed Momenta

declare lower;

#// Copyright (c) 2019-present, Franklin Moormann (cheatcountry)
#// Double Smoothed Momenta [CC] script may be freely distributed under the MIT license.
#study("Double Smoothed Momenta [CC]", overlay=false)

#inp = input(title="Source", type=input.source, defval=close)
#res = input(title="Resolution", type=input.resolution, defval="")
#rep = input(title="Allow Repainting?", type=input.bool, defval=false)
#bar = input(title="Allow Bar Color Change?", type=input.bool, defval=true)
#src = security(syminfo.tickerid, res, inp[rep ? 0 : barstate.isrealtime ? 1 : 0])[rep ? 0 : barstate.isrealtime ? 0 : 1]
#aLength = input(title="ALength", type=input.integer, defval=2, minval=1)
#yLength = input(title="YLength", type=input.integer, defval=5, minval=1)
#zLength = input(title="ZLength", type=input.integer, defval=25, minval=1)
def inp = close;
def res = 0;  # 2nd agg
input rep = no;
input bar = yes;
def src = close;
input aLength = 2;
input yLength = 5;
input zLength = 25;

#hc = highest(src, aLength)
#lc = lowest(src, aLength)
#top = ema(ema(src - lc, yLength), zLength)
#bot = ema(ema(hc - lc, yLength), zLength)
#mom = bot != 0 ? 100 * top / bot : 0
#momEma = ema(mom, zLength)
def hc = highest(src, aLength);
def lc = lowest(src, aLength);
def top = ExpAverage(ExpAverage(close - lc, yLength), zLength);
def bot = ExpAverage(ExpAverage(hc - lc, yLength), zLength);
def mom = if bot != 0 then (100 * top / bot) else 0;
def momEma = ExpAverage(mom, zLength);

#sig = mom > momEma ? 1 : mom < momEma ? -1 : 0
#alertcondition(crossover(sig, 0), "Buy Signal", "Bullish Change Detected")
#alertcondition(crossunder(sig, 0), "Sell Signal", "Bearish Change Detected")
#momColor = sig > 0 ? : sig < 0 ? :
#barcolor(bar ? momColor : na)
#plot(mom, color=momColor, linewidth=2)
#plot(momEma,, linewidth=1)
def sig = if (mom > momEma) then 1 else if mom < momEma then -1 else 0;

plot z1 = mom;
z1.AssignValueColor( if !bar then color.gray
 else if sig > 0 then
 else if sig < 0 then

plot z2 = momEma;

def alertup = sig crosses above 0;
def alertdwn = sig crosses below 0;

alert(alertup, "Buy Signal", alert.BAR, sound.DING);
alert(alertdwn, "Sell Signal", alert.BAR, sound.bell);


New member
@halcyonguy, thank you for your thoughtful translation. Shakeouts during trending trades are a vexing problem and this metric may help. The Double-Smoothed Momenta is similar to the Stochastic Momentum Index although the former may be a bit better for exits in some markets.

I notice both tend to sputter in upwards trending markets such as occurred during the recovery of 2020.

For anyone interested in a comparison of the Double-Smoothed Momenta above to a clear and useful form of the SMI, here is the ASAP SMI (smoothed) kindly shared by @dap711 recently:


declare lower;

input Length = 4;

#Add your indicator code here (if you want to use this as a template) :)
def min_low = Lowest(low, Length+1);
def max_high = Highest(high, Length+1);

def rel_diff = close - (max_high + min_low) / 2;
def range = max_high - min_low;
def avgrel = ExpAverage(ExpAverage(rel_diff, Length), Length );
def avgdiff = ExpAverage(ExpAverage(range, Length), Length);

plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
SMI.DefineColor("Up", GetColor(1));
SMI.DefineColor("Down", GetColor(0));
SMI.AssignValueColor(if SMI > SMI[1] then SMI.color("Up") else SMI.color("Down"));

plot line_0 = 0;
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
333 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

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?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.