Stochastics Momentum Index For ThinkOrSwim

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

Can someone please convert this trading view indicator? Quick search yields nothing with the Authors name in the forum, so doesn't appear to have been converted yet.

https://www.tradingview.com/script/HLbqdCku-Stochastic-Momentum-Index-SMI/

//@version=2
//Stochastic Momentum Index
// Author: Surjith S M (India)
// Copyright: CC 3.0
//Thanks UCSgears, lonestar108
study("Stochastics Momentum Index", shorttitle = "Stoch_MTM")
a = input(10, "Percent K Length")
b = input(3, "Percent D Length")
ob = input(40, "Overbought")
os = input(-40, "Oversold")
// Range Calculation
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
// SMI calculations
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
SMIsignal = ema(SMI,b)
emasignal = ema(SMI, 10)
h0 = hline(40)
h1 = hline(-40)
//Color Definition for Stochastic Line
//col = SMI >= 40 ? green : SMI <= -40 ? red : black
plot(SMIsignal, title="Stochastic", style=line, color=black)
plot(emasignal, title="EMA", style=line, color=red)
level_40 = 40
level_40smi = SMIsignal > level_40 ? SMIsignal : level_40
level_m40 = -40
level_m40smi = SMIsignal < level_m40 ? SMIsignal : level_m40
p1 = plot(level_40)
p2 = plot(level_40smi)
p3 = plot(level_m40)
p4 = plot(level_m40smi)


fill(p1, p2, color=red, transp=40, title='OverSold')
fill(p3, p4, color=green, transp=40, title='OverBought')
find below

CSS:
#//Stochastic Momentum Index
#// Author: Surjith S M (India)
#// Copyright: CC 3.0
#//Thanks UCSgears, lonestar108
#study("Stochastics Momentum Index", shorttitle = "Stoch_MTM")
# Converted by Sam4Cok@Samer800    - 12/2023
declare lower;

input percentKLength = 10;
input percentDLength = 3;
input over_bought = 40.0;
input over_sold = -40.0;

def na = Double.NaN;
def last = isNaN(close);

def min_low = lowest(low, percentKLength);
def max_high = highest(high, percentKLength);
def rel_diff = close - (max_high + min_low)/2;
def diff = max_high - min_low;

def avgrel = ExpAverage(Expaverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(Expaverage(diff, percentDLength), percentDLength);
def  SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;
def SMIsignal = ExpAverage(SMI,percentDLength);
def emasignal = ExpAverage(SMI, 10);
def levelOB = if SMIsignal > over_bought then SMIsignal else over_bought;
def levelOS = if SMIsignal < over_sold then SMIsignal else over_sold;

plot smiLine = SMIsignal;
smiLine.AssignValueColor(if SMIsignal > over_bought then Color.RED else
                         if SMIsignal < over_sold then Color.GREEN else Color.DARK_GRAY);

plot AvgSMI = emasignal;
avgsmi.setDefaultColor(getcolor(5));

plot overbought = if last then na else over_bought;
overbought.setDefaultColor(Color.GRAY);

plot oversold = if last then na else over_sold;
oversold.setDefaultColor(Color.GRAY);

AddCloud(levelOB, over_bought, Color.RED, Color.RED);
AddCloud(over_sold, levelOS, Color.GREEN, Color.GREEN);
#-- END of CODE
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
502 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.
Back
Top