BuyLow_MP_SMI_TriggerSystem for ThinkorSwim

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

@Playstation An excellent effort, you almost have all the right pieces.
Very well done. Here's how I would implement it. Add the following code snippet

Code:
# Plot the Breakout/Breakdown Signals

plot UpSignal = if SMI crosses above AvgSMI then SMI * 0.996 else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.PINK);
UpSignal.SetLineWeight(5);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.HideTitle();

plot DownSignal = if SMI crosses below AvgSMI then SMI * 1.004 else Double.NaN;
DownSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetDefaultColor(Color.YELLOW);
DownSignal.SetLineWeight(5);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.HideTitle();


I noticed that you used the user input variable showBreakoutSignals. Don't forget to define that early in your code.
In case you get stuck, here is the completed code with all the changes incorporated

Code:
# IronRod SMI Histogram (Lower)
# BuyLow
# Modified by tomsk, 1.18.2020 to add breakout/breakdown signals

# V1.0 - 02.09.2015 - BuyLow  - Initial release of IronRod SMI Histogram (Lower) study
# V1.1 - 01.18.2020 - tomsk   - Added the breakout/breakdown signals at @Playstation's request

# MA - yellow hma's are weak, red is bearish, green bullish.
# On the lower (shows hma angle)- anything above (green) the 0 angle line is bullish, below (red) bearish.
#
# The angle size is directly proportional to trend strength, so you easily see increasing or decreasing trend strength/momentum.
# I use the dark/light graduation as a doubling signal for strong moves.

declare lower;

input audioalarm=yes;
input Price = hlc3;
input RsqLength = 5;
input RsqLimit = .5;
input SmiLimit = 30;
input chopband2= 70;
input smibarbufr = 4;
input showBreakoutSignals = yes;

def overbought = SmiLimit;
def oversold = -SmiLimit;
def percentDLength = 4;
def percentKLength = 5;

# Stochastic Momentum Index (SMI)

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);

plot chopband = if IsNaN(close) then Double.NaN else 0;
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;

#SMI.SetDefaultColor(Color.BLUE);

SMI.DefineColor("Up", CreateColor(0, 153, 51));
SMI.definecolor("Weak", Color.LIGHT_GRAY);
SMI.DefineColor("Down", Color.RED);
SMI.AssignValueColor(if SMI > SMI[1] then SMI.Color("Up") else if SMI < SMI[1] then SMI.Color("Down") else SMI.Color("Weak"));
SMI.SetLineWeight(2);
SMI.SetStyle(Curve.SHORT_DASH);
SMI.SetLineWeight(3);

plot AvgSMI = ExpAverage(SMI, percentDLength);

AvgSMI.DefineColor("Up", CreateColor(0, 153, 51));
AvgSMI.definecolor("Weak", Color.LIGHT_GRAY);
AvgSMI.DefineColor("Down", Color.RED);
AvgSMI.AssignValueColor(if AvgSMI > AvgSMI[1] then AvgSMI.Color("Up") else if AvgSMI < AvgSMI[1] then AvgSMI.Color("Down") else AvgSMI.Color("Weak"));
AvgSMI.SetLineWeight(3);

# Plot the Breakout/Breakdown Signals

plot UpSignal = if SMI crosses above AvgSMI then SMI * 0.996 else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.PINK);
UpSignal.SetLineWeight(5);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.HideTitle();

plot DownSignal = if SMI crosses below AvgSMI then SMI * 1.004 else Double.NaN;
DownSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetDefaultColor(Color.YELLOW);
DownSignal.SetLineWeight(5);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.HideTitle();

#SMI1.SetPaintingStrategy(PaintingStrategy.DASHES);

plot SMIBAR = AvgSMI;

SMIBAR.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SMIBAR.SetLineWeight(3);
SMIBAR.DefineColor("Upstrong", CreateColor (0, 255, 0));
SMIBAR.DefineColor("Weak", Color.LIGHT_GRAY);
SMIBAR.DefineColor("Downstrong", CreateColor(255, 51, 51));
SMIBAR.AssignValueColor (if (SMI + smibarbufr) >= SMI[1] and SMI > -SmiLimit then SMIBAR.Color("Upstrong") else if (SMI - smibarbufr) <= SMI[1] and SMI < SmiLimit then SMIBAR.Color("Downstrong") else SMIBAR.Color("Weak"));

# r-Square Centerline Indicator

#def sma = Average(close, RsqLength);
#def RSq = Sqr(WMA(close, RsqLength) - sma) / (Average(Sqr(close), RsqLength) - Sqr(sma)) * 3 * (RsqLength + 1) / (RsqLength - 1);

chopband.HideBubble();
chopband.SetLineWeight(5);
chopband.DefineColor("Trade", CreateColor(0, 150,200));
chopband.DefineColor("Hold", Color.ORANGE);
chopband.AssignValueColor(if SMI > -smiLimit and SMI < smilimit then chopband.Color("Hold") else chopband.Color("Trade"));

# Chop Cloud

plot upper= smilimit;
plot lower= -smilimit;

upper.setDefaultColor(Color.GRAY);
lower.setDefaultColor(Color.GRAY);

def choplimits = SmiLimit;

#input choplimits= 1;

AddCloud(choplimits, -choplimits, CreateColor(210,210,210));

#addcloud(-choplimits, -chopband2, CreateColor(175,175,175));
#addcloud(chopband2, choplimits, CreateColor(175,175,175));

# Labels

AddLabel(yes, "SMI Legend: ", Color.WHITE);
AddLabel(yes, "Bullish", Color.UPTICK);
AddLabel(yes, "Bearish", Color.DOWNTICK);
AddLabel(yes, "Changing", Color.GRAY);
AddLabel(yes, "MidLine: ", Color.WHITE);
AddLabel(yes, "Trending", CreateColor(0,150,200));
AddLabel(yes, "In ChopZone", Color.ORANGE);
AddLabel(yes, "SmiLimit: " + SmiLimit, Color.GRAY);

alert (audioalarm and SMI crosses AvgSMI and SMI <= -smilimit or SMI crosses AvgSMI AND SMI >= smilimit, "SMI CROSS", alert.bar, sound.ring);
# End Study
Good morning. I've recently found the IronRod lower study. Can you speak on if it repaints? Ive spent some time watching it live and I feel like the SMI moves some within a candle or two and can change from green/red. Thoughts?
 
Good morning. I've recently found the IronRod lower study. Can you speak on if it repaints? Ive spent some time watching it live and I feel like the SMI moves some within a candle or two and can change from green/red. Thoughts?
No, the IronRod is not a "repainter"
For prior candles, the calculations used in the IronRod are set and final and do not repaint.

However, this study, like the majority of indicators on this forum, will continually update the current bar until it is closed.
Think about it, we can not know, as a candle is forming, what the final close, high, low, of the current bar is going to be, so of course, it updates with the most recent tick.
 
Last edited:
Folks, seems like there is recent interest in this indicator, so I looked into my files and found the following study from 2015 entitled "IronRod SMI Histogram" that uses SMI and the r-Square Centerline Indicator, complete with color coded legend - bullish, bearish, changing, etc. Thought I'd share with the community here. Just another version for you to play with

Code:
# IronRod SMI Histogram (Lower)
# BuyLow

# MA - yellow hma's are weak, red is bearish, green bullish.
# On the lower (shows hma angle)- anything above (green) the 0 angle line is bullish, below (red) bearish.
#
# The angle size is directly proportional to trend strength, so you easily see increasing or decreasing trend strength/momentum.
# I use the dark/light graduation as a doubling signal for strong moves.

declare lower;

input audioalarm=yes;
input Price = hlc3;
input RsqLength = 5;
input RsqLimit = .5;
input SmiLimit = 30;
input chopband2= 70;
input smibarbufr = 4;

def overbought = SmiLimit;
def oversold = -SmiLimit;
def percentDLength = 4;
def percentKLength = 5;

# Stochastic Momentum Index (SMI)

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);

plot chopband = if IsNaN(close) then Double.NaN else 0;
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;

#SMI.SetDefaultColor(Color.BLUE);

SMI.DefineColor("Up", CreateColor(0, 153, 51));
SMI.definecolor("Weak", Color.LIGHT_GRAY);
SMI.DefineColor("Down", Color.RED);
SMI.AssignValueColor(if SMI > SMI[1] then SMI.Color("Up") else if SMI < SMI[1] then SMI.Color("Down") else SMI.Color("Weak"));
SMI.SetLineWeight(2);
SMI.SetStyle(Curve.SHORT_DASH);
SMI.SetLineWeight(3);

plot AvgSMI = ExpAverage(SMI, percentDLength);

AvgSMI.DefineColor("Up", CreateColor(0, 153, 51));
AvgSMI.definecolor("Weak", Color.LIGHT_GRAY);
AvgSMI.DefineColor("Down", Color.RED);
AvgSMI.AssignValueColor(if AvgSMI > AvgSMI[1] then AvgSMI.Color("Up") else if AvgSMI < AvgSMI[1] then AvgSMI.Color("Down") else AvgSMI.Color("Weak"));
AvgSMI.SetLineWeight(3);

#SMI1.SetPaintingStrategy(PaintingStrategy.DASHES);

plot SMIBAR = AvgSMI;

SMIBAR.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SMIBAR.SetLineWeight(3);
SMIBAR.DefineColor("Upstrong", CreateColor (0, 255, 0));
SMIBAR.DefineColor("Weak", Color.LIGHT_GRAY);
SMIBAR.DefineColor("Downstrong", CreateColor(255, 51, 51));
SMIBAR.AssignValueColor (if (SMI + smibarbufr) >= SMI[1] and SMI > -SmiLimit then SMIBAR.Color("Upstrong") else if (SMI - smibarbufr) <= SMI[1] and SMI < SmiLimit then SMIBAR.Color("Downstrong") else SMIBAR.Color("Weak"));

# r-Square Centerline Indicator

#def sma = Average(close, RsqLength);
#def RSq = Sqr(WMA(close, RsqLength) - sma) / (Average(Sqr(close), RsqLength) - Sqr(sma)) * 3 * (RsqLength + 1) / (RsqLength - 1);

chopband.HideBubble();
chopband.SetLineWeight(5);
chopband.DefineColor("Trade", CreateColor(0, 150,200));
chopband.DefineColor("Hold", Color.ORANGE);
chopband.AssignValueColor(if SMI > -smiLimit and SMI < smilimit then chopband.Color("Hold") else chopband.Color("Trade"));

# Chop Cloud

plot upper= smilimit;
plot lower= -smilimit;

upper.setDefaultColor(Color.GRAY);
lower.setDefaultColor(Color.GRAY);

def choplimits = SmiLimit;

#input choplimits= 1;

AddCloud(choplimits, -choplimits, CreateColor(210,210,210));

#addcloud(-choplimits, -chopband2, CreateColor(175,175,175));
#addcloud(chopband2, choplimits, CreateColor(175,175,175));

# Labels

AddLabel(yes, "SMI Legend: ", Color.WHITE);
AddLabel(yes, "Bullish", Color.UPTICK);
AddLabel(yes, "Bearish", Color.DOWNTICK);
AddLabel(yes, "Changing", Color.GRAY);
AddLabel(yes, "MidLine: ", Color.WHITE);
AddLabel(yes, "Trending", CreateColor(0,150,200));
AddLabel(yes, "In ChopZone", Color.ORANGE);
AddLabel(yes, "SmiLimit: " + SmiLimit, Color.GRAY);

alert (audioalarm and SMI crosses AvgSMI and SMI <= -smilimit or SMI crosses AvgSMI AND SMI >= smilimit, "SMI CROSS", alert.bar, sound.ring);
# End Study

Thank you @tomsk for sharing this.

If interested, I added the SMI Oscillator, Average SMI Oscillator, Histogram Bars, and Midband (Chop/Trend) labels respectively with the option to turn them on or off.


Code:
# IronRod SMI Histogram (Lower)
# BuyLow

# MA - yellow hma's are weak, red is bearish, green bullish.
# On the lower (shows hma angle)- anything above (green) the 0 angle line is bullish, below (red) bearish.
#
# The angle size is directly proportional to trend strength, so you easily see increasing or decreasing trend strength/momentum.
# I use the dark/light graduation as a doubling signal for strong moves.
#
# Added SMI Oscillator, Average SMI Oscillator, Histogram Bars, and Midband (Chop/Trend) labels respectively with the option to turn them on or off.

declare lower;

input showlabels=yes;
input audioalarm=yes;
input Price = hlc3;
input RsqLength = 5;
input RsqLimit = .5;
input SmiLimit = 30;
input chopband2= 70;
input smibarbufr = 4;

def overbought = SmiLimit;
def oversold = -SmiLimit;
def percentDLength = 4;
def percentKLength = 5;

# Stochastic Momentum Index (SMI)

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);

plot chopband = if IsNaN(close) then Double.NaN else 0;
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;

#SMI.SetDefaultColor(Color.BLUE);

SMI.DefineColor("Up", CreateColor(0, 153, 51));
SMI.definecolor("Weak", Color.LIGHT_GRAY);
SMI.DefineColor("Down", Color.RED);
SMI.AssignValueColor(if SMI > SMI[1] then SMI.Color("Up") else if SMI < SMI[1] then SMI.Color("Down") else SMI.Color("Weak"));
SMI.SetLineWeight(2);
SMI.SetStyle(Curve.SHORT_DASH);
SMI.SetLineWeight(3);

plot AvgSMI = ExpAverage(SMI, percentDLength);

AvgSMI.DefineColor("Up", CreateColor(0, 153, 51));
AvgSMI.definecolor("Weak", Color.LIGHT_GRAY);
AvgSMI.DefineColor("Down", Color.RED);
AvgSMI.AssignValueColor(if AvgSMI > AvgSMI[1] then AvgSMI.Color("Up") else if AvgSMI < AvgSMI[1] then AvgSMI.Color("Down") else AvgSMI.Color("Weak"));
AvgSMI.SetLineWeight(3);

#SMI1.SetPaintingStrategy(PaintingStrategy.DASHES);

plot SMIBAR = AvgSMI;

SMIBAR.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SMIBAR.SetLineWeight(3);
SMIBAR.DefineColor("Upstrong", CreateColor (0, 255, 0));
SMIBAR.DefineColor("Weak", Color.LIGHT_GRAY);
SMIBAR.DefineColor("Downstrong", CreateColor(255, 51, 51));
SMIBAR.AssignValueColor (if (SMI + smibarbufr) >= SMI[1] and SMI > -SmiLimit then SMIBAR.Color("Upstrong") else if (SMI - smibarbufr) <= SMI[1] and SMI < SmiLimit then SMIBAR.Color("Downstrong") else SMIBAR.Color("Weak"));

# r-Square Centerline Indicator

#def sma = Average(close, RsqLength);
#def RSq = Sqr(WMA(close, RsqLength) - sma) / (Average(Sqr(close), RsqLength) - Sqr(sma)) * 3 * (RsqLength + 1) / (RsqLength - 1);

chopband.HideBubble();
chopband.SetLineWeight(5);
chopband.DefineColor("Trade", CreateColor(0, 150,200));
chopband.DefineColor("Hold", Color.ORANGE);
chopband.AssignValueColor(if SMI > -smiLimit and SMI < smilimit then chopband.Color("Hold") else chopband.Color("Trade"));

# Chop Cloud

plot upper= smilimit;
plot lower= -smilimit;

upper.setDefaultColor(Color.GRAY);
lower.setDefaultColor(Color.GRAY);

def choplimits = SmiLimit;

#input choplimits= 1;

AddCloud(choplimits, -choplimits, CreateColor(210,210,210));

#addcloud(-choplimits, -chopband2, CreateColor(175,175,175));
#addcloud(chopband2, choplimits, CreateColor(175,175,175));

# Labels

AddLabel(showlabels, if SMI > SMI[1] then "SMI Up" else if SMI < SMI[1] then "SMI Down" else "SMI Weak", if SMI > SMI[1] then SMI.Color("Up") else if SMI < SMI[1] then SMI.Color("Down") else SMI.Color("Weak"));# SMI

AddLabel(showlabels, if AvgSMI > AvgSMI[1] then "Avg SMI Bullish" else if AvgSMI < AvgSMI[1] then "Avg SMI Bearish" else   "Avg SMI Weak", if AvgSMI > AvgSMI[1] then AvgSMI.Color("Up") else if AvgSMI < AvgSMI[1] then AvgSMI.Color("Down") else AvgSMI.Color("Weak"));# Avg SMI

AddLabel(showlabels, if (SMI + smibarbufr) >= SMI[1] and SMI > -SmiLimit then "Strong Uptrend" else if (SMI - smibarbufr) <= SMI[1] and SMI < SmiLimit then "Strong Downtrend" else "Weak", if (SMI + smibarbufr) >= SMI[1] and SMI > -SmiLimit then SMIBAR.Color("Upstrong") else if (SMI - smibarbufr) <= SMI[1] and SMI < SmiLimit then SMIBAR.Color("Downstrong") else SMIBAR.Color("Weak"));# SMI Histogram

AddLabel(showlabels, if SMI > -smiLimit and SMI < smiLimit then "Chop" else "Trend", if SMI > -smiLimit and SMI < smiLimit then chopband.Color("Hold") else chopband.Color("Trade"));# MidBar/Line

#Coded out the Legend

#AddLabel(yes, "SMI Legend: ", Color.WHITE);
#AddLabel(yes, "Bullish", Color.UPTICK);
#AddLabel(yes, "Bearish", Color.DOWNTICK);
#AddLabel(yes, "Changing", Color.GRAY);
#AddLabel(yes, "MidLine: ", Color.WHITE);
#AddLabel(yes, "Trending", CreateColor(0,150,200));
#AddLabel(yes, "In ChopZone", Color.ORANGE);
#AddLabel(yes, "SmiLimit: " + SmiLimit, Color.GRAY);

alert (audioalarm and SMI crosses AvgSMI and SMI <= -smilimit or SMI crosses AvgSMI AND SMI >= smilimit, "SMI CROSS", alert.bar, sound.ring);
# End Study
 
Last edited:
Thread starter Similar threads Forum Replies Date
S Smart Money Index (SMI) Indicator for ThinkorSwim Indicators 29

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
324 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