BuyLow_MP_SMI_TriggerSystem for ThinkorSwim

J007RMC

J007RMC

Active member
2019 Donor
VIP
I came across this recently and added the MACD histogram. This looks like and great combination and plan to use this today.

Code:
#Created by Buy Low and given permission to share
#Renamed SMI Trigger System by Hguru
#IronRod Lower (may2015)- hull smoothed SMI with AwsomeOscillator histogram
#  ribbonStudy added- based on distance between midprice and ema(20)
# This is the smi-based lower Ive been using for quite a while:  I look for red on red and green on green for trading, where for example both the cloud is red and the smi dashed line is red.  Most reliable and easy to read signals Ive found.

#Look for the Dashed lines to turn color and Avg line to cross the Dash line for an entry but with more risk, next entry when avg line and dashed color line  crosses the 40 line. Next and probably the best risk is when the avg line and dashed line cross the zero line and Dashed line and cloud are the same color. I use this with a MACD crossover arrow setting at 5,13,4 or 5,13,6 or 3,13,6

#Not 100% on the ADX vertical line and histogram this might need to be adjusted to match a normal ADX line. The ADX vertical line can be turned off in the edit study. The hisotgram can be hidden as well.

#Use with the Upper matching MP_SMIandVerticalLineWarning System  here>>>  https://tos.mx/mDvxaX

#use setting gridsize .10 for/CL for tick charts and lower agg time frames and 1.0 for 1 hour and Daily.

declare lower;
#SMI engine
input gridsize = 1.0;
input aoscale = 1;
input smiscale = 100;
input audio = yes;
input label = yes;
input smilimit = 40.0;
input adxvline = yes;
def aofast = 5;
def aoslow = 34;

def percentDLength = 3;
def percentKLength = 5;
def smihull = 3;
def anglescalingfactor = 1 / gridsize;

def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diffx = max_high - min_low;

def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diffx, percentDLength), percentDLength);
#plot SMI =  if avgdiff != 0 then avgrel / (avgdiff / 2) * smiscale else 0;
plot SMI = ExpAverage( if avgdiff != 0 then avgrel / (avgdiff / 2) * smiscale else 0, 3);
#smi.setDefaultColor(getColor(1));
SMI.DefineColor("Up", Color.DARK_GREEN);
SMI.DefineColor("Down", Color.DOWNTICK);
SMI.DefineColor("flat", Color.GRAY);
SMI.AssignValueColor(if SMI >= SMI[1] then SMI.Color("up") else SMI.Color("down"));
SMI.SetLineWeight(4);
SMI.SetStyle(Curve.SHORT_DASH);

plot SMI1 = if avgdiff != 0 then avgrel / (avgdiff / 2) * smiscale else 0;
SMI1.SetDefaultColor(Color.GRAY);

plot upper = smilimit;
upper.SetDefaultColor(Color.BLUE);

plot lower = -smilimit;
lower.SetDefaultColor(Color.BLUE);

# Awesome Oscillator

plot Zero = 0;
Zero.SetDefaultColor(Color.DARK_GRAY);

#AddCloud(SMI, smilimit, Color.GREEN, Color.LIGHT_GRAY);
#AddCloud(-smilimit, SMI, Color.RED, Color.LIGHT_GRAY);
AddCloud(SMI, 0, Color.LIGHT_GREEN, CreateColor(255, 50, 50));

Alert(audio and SMI crosses above 0, "SMI Long",  Alert.BAR, Sound.Ring);
Alert(audio and SMI crosses below 0, "SMI Short",  Alert.BAR, Sound.Ring);
Alert(audio and SMI crosses smilimit, "", Alert.BAR, Sound.Bell);
upper.SetDefaultColor(Color.RED);
#upper.SetStyle(Curve.SHORT_DASH);
lower.SetDefaultColor(Color.UPTICK);
#lower.SetStyle(Curve.SHORT_DASH);

#AddCloud(diff, SMI, Color.DOWNTICK, Color.UPTICK);
AddLabel(label and yes, "Dashed= SMI, cloud w/limit; Histogram = mAwesomeOscillator" , Color.BLUE);
 
#adx histogram
input length = 10;
input averageType = AverageType.WILDERS;

plot ADX = (DMI(length, averageType).ADX) - 18;
ADX.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ADX.SetLineWeight(1);
ADX.DefineColor("Up", Color.BLUE);
ADX.DefineColor("Down", Color.DARK_ORANGE);
ADX.AssignValueColor(
      if ADX >= ADX[1] then ADX.Color("up")
 else ADX.Color("down"));
plot adxcaut = 20;
adxcaut.SetDefaultColor(Color.DARK_ORANGE);

AddVerticalLine (adxvline and ADX >= 1 and ADX < ADX[1] and ADX[1] > ADX[2], "mADX", Color.BLUE);
#alert(ADX1 >= 1 and ADX1 < ADX1[1] and ADX1[1] > ADX1[2], alert.bar, sound.bell);
https://tos.mx/eHobhf7
 
T

Trading51

Active member
2019 Donor
the second post, the middle indicator is there any rules on how to apply this?
 
J007RMC

J007RMC

Active member
2019 Donor
VIP
Huhm, all I know is explained in the first post. I'm taking it for a spin today.
 
J007RMC

J007RMC

Active member
2019 Donor
VIP
viewing this system seems to work very well on an hourly chart
 
D

dolomick

Member
This looks good! Do you know why there is a horizontal orange line at 20 on the indicator - I didn't see much about that in the comments in the code. Thanks for sharing, this really looks good.
 
Last edited:
J007RMC

J007RMC

Active member
2019 Donor
VIP
Wish I knew more about this indicator perhaps a coder can take a look into it.
 
horserider

horserider

Well-known member
VIP
Tells you in the header " hull smoothed SMI with MACD/hull histogram"

As can see below it is applying a hull moving avg to the SMI

def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diffx, percentDLength), percentDLength);
plot SMI = hullMovingAvg( if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0,smihull);


def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diff, percentDLength), percentDLength);
plot SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;


For MACD just uses Hull in place of EXPONENTIAL

input averageType = AverageType.HULL;
input macdscaling = 50;
def Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
def Avg = MovingAverage(averageType, Value, MACDLength);
plot Macd = (Value - Avg) * macdscaling;


input averageType = AverageType.EXPONENTIAL;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);
plot Avg = MovingAverage(averageType, Value, MACDLength);
plot Diff = Value - Avg;
 
horserider

horserider

Well-known member
VIP
Here is an SMI and Hull MACD comparison to this study. I do not get a HULL MACD at all?

 
D

dolomick

Member
@horserider I'm not sure if you were responding to me or not. The first indicator looks very useful, my question was regarding the significance of the orange horizontal line marked at level 20 in the first indicator.

Some observations - there seems to be no Awesome Oscillator, so the label is wrong that comes with the first indicator. It seems to be an ADX histogram that is plotted, not an awesome oscillator.

With regards to the second Hull smoothed MACD, I'm struggling to see its usefulness as well. Maybe someone else can see a use for it, if so please post.
 
horserider

horserider

Well-known member
VIP
@dolomick Ahh the study at the top of the post. Strange that it defines Awesome Oscillator inputs but never seems to use them.
It is an ADX histogram. The orange line at 20 seems to be the level chosen to define if the ADX is strong or weak.
If I planned to use that study I would change the ADX histogram to a line. Much clearer to read that way.
 
T

tomsk

Well-known member
VIP
@J007RMC Thanks for posting the study, when I have some free time I might look into the guts of this study. Tied up on other projects at the moment.
 
J007RMC

J007RMC

Active member
2019 Donor
VIP
i am using just the first adx lower study and it seems to be extremely accurate for price direction and works on mobile a plus.
 
Last edited:
T

tomsk

Well-known member
VIP
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
 
D

dolomick

Member
Ooh this is another good one, thanks for this! It's hard to see which I like better. This one has nice signals built in, but the first one posted has the ADX which I like. Although, I notice the ADX is a little behind the price action, probably because it's using Wilders. I played with other avg types in the dropdown but a lot of them seemed to mess with the scaling and get the oscillator too big, so I kept it as is. I would love to find some settings for the ADX that responded a little faster so we could see when the move was getting exhausted a little faster. Open to suggestions...
 
S

Shrum

New member
What is painting the arrows on the top part of your chart?
 
D

dolomick

Member
ADX = 1 Some studies will not plot it.
Do you mean ADX input length set to 1?

Another thing I don't understand about the ADX histogram on this (awesome) indicator is why it sometimes goes negative? The ADX normally goes to a low of 0 so I am not sure what is going on in that case? Can anyone make it more like a normal ADX?
 
Last edited:
horserider

horserider

Well-known member
VIP
@dolomick No inputs for some lengths so modified in code. No idea how you trade. See it this works for you.

Code:
#Created by Buy Low and given permission to share
#Renamed SMI Trigger System by Hguru
#IronRod Lower (may2015)- hull smoothed SMI with AwsomeOscillator histogram
#  ribbonStudy added- based on distance between midprice and ema(20)
# This is the smi-based lower Ive been using for quite a while:  I look for red on red and green on green for trading, where for example both the cloud is red and the smi dashed line is red.  Most reliable and easy to read signals Ive found.

#Look for the Dashed lines to turn color and Avg line to cross the Dash line for an entry but with more risk, next entry when avg line and dashed color line  crosses the 40 line. Next and probably the best risk is when the avg line and dashed line cross the zero line and Dashed line and cloud are the same color. I use this with a MACD crossover arrow setting at 5,13,4 or 5,13,6 or 3,13,6

#Not 100% on the ADX vertical line and histogram this might need to be adjusted to match a normal ADX line. The ADX vertical line can be turned off in the edit study. The hisotgram can be hidden as well.

#Use with the Upper matching MP_SMIandVerticalLineWarning System  here>>>  https://tos.mx/mDvxaX

#use setting gridsize .10 for/CL for tick charts and lower agg time frames and 1.0 for 1 hour and Daily.

declare lower;
#SMI engine
input gridsize = 1.0;
input aoscale = 1;
input smiscale = 100;
input audio = yes;
input label = yes;
input smilimit = 40.0;
input adxvline = yes;

def percentDLength = 13;
def percentKLength = 21;
def smihull = 5;
def anglescalingfactor = 1 / gridsize;

def min_low = Lowest(low, percentKLength);
def max_high = Highest(high, percentKLength);
def rel_diff = close - (max_high + min_low) / 2;
def diffx = max_high - min_low;

def avgrel = ExpAverage(ExpAverage(rel_diff, percentDLength), percentDLength);
def avgdiff = ExpAverage(ExpAverage(diffx, percentDLength), percentDLength);
#plot SMI =  if avgdiff != 0 then avgrel / (avgdiff / 2) * smiscale else 0;
plot SMI = ExpAverage( if avgdiff != 0 then avgrel / (avgdiff / 2) * smiscale else 0, 3);
#smi.setDefaultColor(getColor(1));
SMI.DefineColor("Up", Color.DARK_GREEN);
SMI.DefineColor("Down", Color.DOWNTICK);
SMI.DefineColor("flat", Color.GRAY);
SMI.AssignValueColor(if SMI >= SMI[1] then SMI.Color("up") else SMI.Color("down"));
SMI.SetLineWeight(4);
SMI.SetStyle(Curve.SHORT_DASH);

plot SMI1 = if avgdiff != 0 then avgrel / (avgdiff / 2) * smiscale else 0;
SMI1.SetDefaultColor(Color.GRAY);

plot upper = smilimit;
upper.SetDefaultColor(Color.BLUE);

plot lower = -smilimit;
lower.SetDefaultColor(Color.BLUE);



plot Zero = 0;
Zero.SetDefaultColor(Color.DARK_GRAY);

#AddCloud(SMI, smilimit, Color.GREEN, Color.LIGHT_GRAY);
#AddCloud(-smilimit, SMI, Color.RED, Color.LIGHT_GRAY);
AddCloud(SMI, 0, Color.LIGHT_GREEN, CreateColor(255, 50, 50));

Alert(audio and SMI crosses above 0, "SMI Long",  Alert.BAR, Sound.Ring);
Alert(audio and SMI crosses below 0, "SMI Short",  Alert.BAR, Sound.Ring);
Alert(audio and SMI crosses smilimit, "", Alert.BAR, Sound.Bell);
upper.SetDefaultColor(Color.RED);
#upper.SetStyle(Curve.SHORT_DASH);
lower.SetDefaultColor(Color.UPTICK);
#lower.SetStyle(Curve.SHORT_DASH);

#AddCloud(diff, SMI, Color.DOWNTICK, Color.UPTICK);
AddLabel(label and yes, "Dashed= SMI, cloud w/limit; Histogram = mAwesomeOscillator" , Color.BLUE);
 
#adx histogram
input length = 5;
input averageType = AverageType.WILDERS;

plot ADX = (DMI(length, averageType).ADX) - 18;
ADX.SetPaintingStrategy(PaintingStrategy.LINE);
ADX.SetLineWeight(1);
ADX.DefineColor("Up", Color.BLUE);
ADX.DefineColor("Down", Color.DARK_ORANGE);
ADX.AssignValueColor(
      if ADX >= ADX[1] then ADX.Color("up")
 else ADX.Color("down"));
plot adxcaut = 20;
adxcaut.SetDefaultColor(Color.DARK_ORANGE);

AddVerticalLine (adxvline and ADX >= 1 and ADX < ADX[1] and ADX[1] > ADX[2], "mADX", Color.BLUE);
#alert(ADX1 >= 1 and ADX1 < ADX1[1] and ADX1[1] > ADX1[2], alert.bar, sound.bell);
 
D

dolomick

Member
Thanks for this... I put it up next to the old one, and the SMI is behaving differently, while the only thing I wanted to behave differently was the ADX portion. I'm wondering if some of the changes inadvertantly changed the behavior of the SMI portion?

As I put both up, the modified one seems to react slower on the SMI and catch bigger trends on the one minute chart, while the original could be used for precise entries. Weird.
 
Last edited:
Thread starter Similar threads Forum Replies Date
S Smart Money Index (SMI) Indicator for ThinkorSwim? Questions 21
P SMI Ergodic Indicator for ThinkorSwim? Questions 4

Similar threads

Top