BuyLow_MP_SMI_TriggerSystem for ThinkorSwim

ADX = 1 Does not work for this study ADX. It was coded at 5 if my memory is correct. I just changed some inputs as I hate any oscillator swinging too wildly.
 

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

After working extensively with the original buy Lo study with addition to placing Tomsk ironrod onto the lower study A_BuyLow_MP_SMI_TriggerSystem1 for absolute smi. this gives me a clearer easy to read stochastic tops and bottoms in accordance to the original smi and macd trends on any time frame. Thanks to the site and coders for helping me find a path.
 
After working extensively with the original buy Lo study with addition to placing Tomsk ironrod onto the lower study A_BuyLow_MP_SMI_TriggerSystem1 for absolute smi. this gives me a clearer easy to read stochastic tops and bottoms in accordance to the original smi and macd trends on any time frame. Thanks to the site and coders for helping me find a path.
Can you share a chart that has this setup? I really like the original buy lo study as well but I’m curious to look at what you are now using. Thanks!
 
What I find is so facinationing regarding trading is I always return to the stochastic and MACD in one way or another. And Ive tried soo many chart combinations but for the basic lower indicators Im sold.
 
Have you guys seen this version?

Upper Study

Code:
#FUTURES Iron Rod Upper 9.0 (14/9/10)- same as ver 8c
#applieS hma angle + minimum angle logic to ir lines, background options, labels, and alarms.
#IMPORTANT NOTE:  Need to adjust anglegscalingfactor to achieve $1 increments on price legend to calibrate angle logic 

declare upper;
input FutureSymbol = {default stock1 , TF, CL, ES, Stock2};
input showBubbles = yes;
input labels = yes;
input mADXVLine = yes;
input SMIarrows = no;
input IRGarrows = yes;
input audioalarm = yes;
input Candle_Color = {default midprice, Smi, Hma};
input Background_Type = {default IRdirection, Smi , slowsmiandhma, Dark, Light, angles};
input paintBars = yes;

input minangle = 12;
#input anglescalingfactor = 1.0;

input fasthma = 8;
input slowhma = 15;
input angleperiod = 5;
input shorttrend = 21;
input longtrend = 55;
input lrlength = 15;
input MidCandleType = hlc3;
input MidCandleWeight = 2;
input hullsmi = 8;
input smilimit = 12;

input stdevLength = 55;
input numStdev = 1.0;
input SDBinner = .75;
input sdbouter = 1.25;

input shortlabel = 20;
input midlabel = 50;
input longlabel = 90;

input smibarbufr = 4;
input vlbuffer = 0;
input arrowbuffer = 20;
input anglelength = 2;
#input reversalAmount = 2.0;

#input BubbleDisplace=1.5;
#input TicksPerPoint=10;
#input DollarPerTick=10;
#input FuturesTraded = 1;

def MAtype = hlc3;
def anglescalingfactor;
def reversalAmount;
def BubbleDisplace;
def TicksPerPoint;
def DollarPerTick;
def futurestraded;

switch (FutureSymbol){
case TF:
    anglescalingfactor = 1.0;
    reversalAmount = 1.5;
    BubbleDisplace = 1.5;
    TicksPerPoint = 10;
    DollarPerTick = 10;
    futurestraded = 5;
case CL:
    anglescalingfactor = 10.0;
    reversalAmount = .2;
    BubbleDisplace = .2;
    TicksPerPoint = 100;
    DollarPerTick = 10;
    futurestraded = 5;
case ES:
    anglescalingfactor = 1.0;
    reversalAmount = .2;
    BubbleDisplace = .2;
    TicksPerPoint = 4;
    DollarPerTick = 12.50;
    futurestraded = 5;
case Stock2:
    anglescalingfactor = 2;
    reversalAmount = 2.0;
    BubbleDisplace = 1.5;
    TicksPerPoint = 1;
    DollarPerTick = 1;
    futurestraded = 1;
default:
    anglescalingfactor = 1.0;
    reversalAmount = 1.5;
    BubbleDisplace = 1.5;
    TicksPerPoint = 1;
    DollarPerTick = 1;
    futurestraded = 1;
}
#  Hull modified Smi-> generates arrows, used for irg colors
def percentDLength = 4;
def percentKLength = 5;
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 AvgSMI = HullMovingAvg(SMI, hullsmi);

#IRON ROD lines-
#IronRod (IRg) guideline
    #Slope to Angle conversion
plot ir = HullMovingAvg(hlc3, slowhma);
def ira = ir - ir[anglelength];
def irangle = Round((anglescalingfactor * (ATan(ira / anglelength) * 180 / Double.Pi)), 1);
plot irg = HullMovingAvg(hlc3, fasthma);
def irgang = HullMovingAvg(hlc3, angleperiod);
def irga = irgang - irgang[anglelength];
def irgangle = Round((anglescalingfactor * (ATan(irga / anglelength) * 180 / Double.Pi)), 1);

#Iron Rod control line (IR)
ir.DefineColor("Up", Color.UPTICK);
ir.DefineColor("weak", CreateColor(50, 150, 250));
ir.DefineColor("Down", Color.DOWNTICK);
ir.AssignValueColor(if irangle >= 5 then ir.Color("up") else if irangle <= -5 then ir.Color("down") else ir.Color("weak"));
#ir.AssignValueColor(if irangle >= 0 then ir.Color("up")else ir.Color("down"));
ir.SetLineWeight(3);

#IronRod Guideline- colored by irg angle
irg.DefineColor("Up", Color.UPTICK);
irg.DefineColor("weak", CreateColor(50, 150, 250));
irg.DefineColor("Down", Color.DOWNTICK);
#irg.AssignValueColor(if IRgangle >=0 then irg.Color("up") else if IRgangle < 0 then irg.Color("down") else irg.Color("weak"));
irg.AssignValueColor(if irgangle >= minangle then irg.Color("up") else if irgangle <= -minangle then irg.Color("down") else irg.Color("weak"));
#irg.AssignValueColor(if IRgangle >= 8 then irg.Color("up") else if IRgangle <= -8 then irg.Color("down") else irg.Color("weak"));
#irg.AssignValueColor(if (AvgSMI >= AvgSMI[1]) then irg.Color("up") else irg.Color("down"));
irg.SetLineWeight(3);
irg.SetStyle(Curve.SHORT_DASH);

#IronRod candle modifications (hybrid Jap/heikinAshi)
plot IRmidprice = SimpleMovingAvg(MidCandleType, 1);
IRmidprice.SetDefaultColor(Color.BLACK);
IRmidprice.SetLineWeight(MidCandleWeight);
IRmidprice.SetPaintingStrategy(PaintingStrategy.DASHES);

plot Pricedot = SimpleMovingAvg(close, 1);
Pricedot.SetStyle(Curve.POINTS);
Pricedot.SetDefaultColor(Color.BLUE);
Pricedot.SetLineWeight(3);
def hmas = ir;

#Linear Regession (LR) Trend Line
def price = hl2;
plot LR = InertiaAll(price, lrlength);
LR.SetDefaultColor(Color.GRAY);

#STANDARD DEVIATION BAND AND CLOUD
plot LRb = InertiaAll(price, stdevLength);
def sdev = StDev(price, stdevLength);
plot SdUB = LRb + numStdev * sdev;
plot SdLB = LRb - numStdev * sdev;
def band = SdUB - SdLB;
LRb.SetDefaultColor(Color.DARK_GREEN);
SdUB.SetDefaultColor(Color.GRAY);
SdUB.SetStyle(Curve.MEDIUM_DASH);
SdUB.SetLineWeight(1);
SdLB.SetDefaultColor(Color.GRAY);
SdLB.SetStyle(Curve.MEDIUM_DASH);
SdLB.SetLineWeight(1);

#Std Dev CLOUDS
AddCloud( (LRb + sdbouter * sdev), (LRb + SDBinner * sdev), CreateColor(175, 175, 175));
AddCloud((LRb - SDBinner * sdev), (LRb - sdbouter * sdev), CreateColor(175, 175, 175));

def lra = LRb - LRb[anglelength];
def lrbangle = Round(((ATan(lra / anglelength) * 180 / Double.Pi)), 2);
#plot rolling= lrangle < minangle and lrangle > -minangle and band >= minrange ;

#EMA Trend Lines
plot LTrend = MovAvgExponential(MAtype, longtrend);
LTrend.SetDefaultColor(Color.BLUE);
LTrend.SetLineWeight(1);

# Candle Coloration
def greenprice;
def redprice;
plot Bullish = greenprice;
plot Bearish = redprice;
plot Neutral = !greenprice and !redprice;
Bullish.Hide();
Neutral.Hide();
Bearish.Hide();

# CANDLE COLOR OPTIONS
switch (Candle_Color){
case Smi:
    greenprice =  (SMI + smibarbufr) >= SMI[1] and SMI > -smilimit;
    redprice =   (SMI - smibarbufr) <= SMI[1] and SMI < smilimit;
case Hma:
    greenprice = ir > ir[1] and irg > irg[1];
    redprice = ir < ir[1] and irg < irg[1];
default:
    greenprice = close > HLC3[1];
    redprice = close < HLC3[1];
}
DefineGlobalColor("Bullish", CreateColor(0, 250, 0));
DefineGlobalColor("Neutral", Color.LIGHT_GRAY);
DefineGlobalColor("Bearish", CreateColor(255, 150, 150));
AssignPriceColor(if !paintBars then Color.CURRENT else if greenprice then GlobalColor("Bullish") else if redprice then GlobalColor("Bearish") else GlobalColor("Neutral"));

#BACKGROUND COLOR OPTIONS
def background;
switch (Background_Type){
case slowsmiandhma:
    background = 1;
case Smi:
    background = 2;
case Dark:
    background = 4;
case Light:
    background = 0;
case angles:
    background = 5;
default:
    background = 3;
}
AssignBackgroundColor(
#Slowsmiandhma
   if background == 1 and AvgSMI > AvgSMI[1] and ir > ir[1] then CreateColor(240, 255, 240)
   else if background == 1 and AvgSMI <= AvgSMI[1] and ir < ir[1] then CreateColor(255, 240, 240)

#smi
        else if background == 2 and SMI > AvgSMI and SMI > smilimit then CreateColor(240, 255, 240)
   else if background == 2 and SMI < AvgSMI and SMI < -smilimit then CreateColor(255, 240, 240)
# IR (default)
   else if background == 3 and ir >= ir[1] and irg >= irg[1] then CreateColor(235, 255, 235)
   else if background == 3 and ir <= ir[1] and irg <= irg[1] then CreateColor(255, 225, 225)
#dark blue
   else if background == 4 then CreateColor(0, 0, 100)
#light gray
else if background == 0 then CreateColor(220, 220, 220)
#Iron Rod Angles
    else if background == 5 and irgangle >= 0 then CreateColor(220, 255, 220)
    else if background == 5 and irgangle < 0 then CreateColor(255, 220, 220)
else CreateColor(220, 220, 220));

#LABELS
def range = high[1] - low[1];
def ATR = Average(TrueRange(high, close, low), 5);
def mva = HullMovingAvg(close(period = AggregationPeriod.DAY), 10);
def fastma = ExpAverage(close(period = AggregationPeriod.DAY), shortlabel);
def mediumma = ExpAverage(close(period = AggregationPeriod.DAY), midlabel);
def longma = ExpAverage(close(period = AggregationPeriod.DAY), longlabel);

AddLabel(yes, "ASF= " + anglescalingfactor + "; MinAngle= " + minangle, Color.BLACK);
AddLabel(labels and yes, "Stock Longterm Profile (days): ", Color.BLACK);
AddLabel(labels and mva > fastma, "Short- " + shortlabel, Color.DARK_GREEN);
AddLabel(labels and mva < fastma, "Short- " + shortlabel, Color.RED);
AddLabel(labels and fastma > mediumma, "Mid- " + midlabel, Color.DARK_GREEN);
AddLabel(labels and fastma < mediumma, "Mid- " + midlabel, Color.RED);
AddLabel(labels and mediumma > longma, "Long- " + longlabel, Color.DARK_GREEN);
AddLabel(labels and mediumma < longma, "Long- " + longlabel, Color.RED);

AddLabel(labels and yes, "  ", Color.WHITE);

AddLabel(labels and (lrbangle >= 5), "1-StdDev Band= " + lrbangle + "deg; " + (sdev * 2) + "  ( " + ((sdev * 2) / ATR) + " atr's  )", Color.DOWNTICK);
AddLabel(labels and (lrbangle <5 and lrbangle > -5), "1-StdDev band= " + lrbangle + "deg; " + (sdev * 2) + "  ( " + ((sdev * 2) / ATR) + " atr's  )", Color.GRAY);
AddLabel(labels and (lrbangle <= -5), "1-StdDev band= " + lrbangle + "deg; " + (sdev * 2) + "  ( " + ((sdev * 2) / ATR) + " atr's  )", Color.UPTICK);

#addlabel(yes, "SMI Profile: "=smi +"/ "+ avgsmi, color.black);
AddLabel(labels and yes, "Range: High= " + (Highest(ATR, 20)), Color.BLUE);
AddLabel(labels and yes, "Trail >" + (ATR), Color.MAGENTA);


AddLabel(labels and yes, "Iron Rod short term profile:", Color.BLACK);
AddLabel(labels and yes, "  ", Color.WHITE);

AddLabel(labels and SMI >= SMI[1] and (SMI < -smilimit or SMI > smilimit) , "SMI", Color.UPTICK);
AddLabel(labels and SMI <= SMI[1] and (SMI < -smilimit or SMI > smilimit), "SMI", Color.RED);
AddLabel(labels and SMI <= smilimit and SMI >= -smilimit, " SMI Choppy ", Color.GRAY);

AddLabel(labels and yes, " ", Color.WHITE);

AddLabel(irgangle >= minangle, fasthma + " Guide= " + irgangle + " deg" , Color.UPTICK);
AddLabel(irgangle < minangle and irgangle > -minangle, fasthma + " Guide= " + irgangle + " deg", Color.BLUE);
AddLabel(irgangle <= -minangle, fasthma + " Guide= " + irgangle + " deg", Color.RED);

AddLabel(irangle >= minangle, slowhma + " IronRod= " + irangle + " deg" , Color.UPTICK);
AddLabel(irangle < minangle and irangle > -minangle, slowhma + " IronRod= " + irangle + " deg", Color.BLUE);
AddLabel(irangle <= -minangle, slowhma + " IronRod= " + irangle + " deg" , Color.RED);

AddLabel(irangle < minangle and irgangle < minangle and irangle > -minangle and irgangle > -minangle, "EXIT", Color. BLUE);
AddLabel(irangle < minangle and irgangle >= minangle, "1x", Color. UPTICK);
AddLabel(irangle > -minangle and irgangle <= -minangle, "1X", Color.DOWNTICK);
AddLabel(irangle >= minangle and irgangle < minangle, "HOLD", Color. UPTICK);
AddLabel(irangle <= -minangle and irgangle > minangle, "HOLD", Color.DOWNTICK);
AddLabel(irangle >= minangle and irgangle >= minangle, "2x", Color. UPTICK);
AddLabel(irangle <= -minangle and irgangle <= -minangle, "2X", Color.DOWNTICK);
#AddLabel(((sdev * 2) / ATR) <= 2, "Narrow Channela", Color.DARK_ORANGE);
AddLabel(band <= 3, "Narrow Channel", Color.DARK_ORANGE);

def pm= irg - lrb;
AddLabel(pm>=3, "PriceMagnet= " + pm, Color.DARK_red);
AddLabel(pm>=1 and pm <3, "PriceMagnet= " + pm, Color.light_red);
AddLabel(pm<1 and pm >-1, "PriceMagnet= " + pm, Color.DARK_orange);
AddLabel(pm<=-1 and pm > -3, "PriceMagnet= " + pm, Color.light_green);
AddLabel(pm<= -3, "PriceMagnet= " + pm, Color.DARK_green);

#mADX and Vertical Line Warning- magnified and centered on midline
def ADX1 = 2.5 * ((DMI(10).ADX) - 25);
AddVerticalLine(mADXVLine and ADX1 >= 1 and ADX1 < ADX1[1] and ADX1[1] > ADX1[2], "mADX TrendChange", Color.BLUE);


#ARROW Indicators
#Small Arrows- based on irg angle crossing midline
plot irgarrowup = (IRGarrows and irgangle[2] < irgangle[3] and irgangle[1] < irgangle[2] and irgangle > irgangle[1]);
irgarrowup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
irgarrowup.SetDefaultColor(Color.UPTICK);
irgarrowup.SetLineWeight(1
);

plot irgarrowdn = (IRGarrows and irgangle[2] > irgangle[3] and irgangle[1] > irgangle[2] and irgangle < irgangle[1]);
irgarrowdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
irgarrowdn.SetDefaultColor(Color.DOWNTICK);
irgarrowdn.SetLineWeight(1);

#plot irgarrowup1 = (IRGarrows and irgangle[2] < irgangle[3] and irgangle[1] < irgangle[2] and irgangle > irgangle[1]);
plot irgarrowup1 = (IRGarrows and irgangle crosses above 0);
irgarrowup1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
irgarrowup1.SetDefaultColor(Color.UPTICK);
irgarrowup1.SetLineWeight(5);

#plot irgarrowdn1 = (IRGarrows and irgangle[2] > irgangle[3] and irgangle[1] > irgangle[2] and irgangle < irgangle[1]);
plot irgarrowdn1 = (IRGarrows and irgangle crosses below 0);
irgarrowdn1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
irgarrowdn1.SetDefaultColor(Color.DOWNTICK);
irgarrowdn1.SetLineWeight(5);

# Smi arrows, based on smi line crossing smi limit lines
plot smiarrowup = (SMIarrows and SMI crosses above -smilimit);
smiarrowup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
smiarrowup.SetDefaultColor(Color.PLUM);
smiarrowup.SetLineWeight(3);

plot smiarrowdn = (SMIarrows and SMI crosses below smilimit);
smiarrowdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
smiarrowdn.SetDefaultColor(Color.PLUM);
smiarrowdn.SetLineWeight(3);

#Zigzag bubbles-  w/convertion to dollars:
Assert(reversalAmount > 0, "'reversal amount' should be positive: " + reversalAmount);

def "ZZ$" = reference ZigZagHighLow(hl2, hl2, 0, reversalAmount, 1, 0);

def zzSave = if !IsNaN("ZZ$") then hl2 else GetValue(zzSave, 1);
def chg = ( hl2 - GetValue(zzSave, 1)) * TicksPerPoint * DollarPerTick * futurestraded;
def isUp = chg >= 0;
def isConf = AbsValue(chg) >= reversalAmount or (IsNaN(GetValue("ZZ$", 1)) and GetValue(isConf, 1));

#"ZZ$".EnableApproximation();
#"ZZ$".DefineColor("Up Trend", Color.BLUE);
#"ZZ$".DefineColor("Down Trend", Color.BLUE);
#"ZZ$".DefineColor("Undefined", Color.LIGHT_GRAY);
#"ZZ$".AssignValueColor(if !isConf then "ZZ$".Color("Undefined") else if isUp then "ZZ$".Color("Up Trend") else #"ZZ$".Color("Down Trend"));

DefineGlobalColor("Unconfirmed", Color.LIGHT_GRAY);
DefineGlobalColor("Up", Color.UPTICK);
DefineGlobalColor("Down", Color.DOWNTICK);

def barNumber = BarNumber();

AddChartBubble(showBubbles and !IsNaN("ZZ$") and barNumber != 1 and chg >= 0, (price + BubbleDisplace), "$ " + chg, Color.UPTICK);
AddChartBubble(showBubbles and !IsNaN("ZZ$") and barNumber != 1 and chg <= 0, ( (price - (2 * BubbleDisplace))), "$" + -chg, Color.DOWNTICK);

#end of Iron Rod upper study script

Lower Study

Code:
#IronRod Lower futures study
#Important to set anglescalingfactor to $1 grid equivalence

declare lower;
input audioalarm = yes;
input angscalingfactor = 1;
input minangle = 12;
input Price = hlc3;
input SmiLimit = 12;
input fasthma = 5;
input slowhma = 15;

input barplace= 35;
input tsplace = 40;
input tsmult=15;
input anglelength= 2;

#Stochastic momentum index (SMI)
def smibuffer = 10;
def hullength = 10;
def percentDLength = 4;
def percentKLength = 5;
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 SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 25 else 0;
def AvgSMI = HullMovingAvg(SMI, hullength);
sMI.setDefaultColor(color.PLUM);
SMI.SetLineWeight(1);

#Chop Cloud
plot upper = minangle;
plot lower = -minangle;
upper.SetDefaultColor(Color.GRAY);
lower.SetDefaultColor(Color.GRAY);
#AddCloud(upper, lower, CreateColor(180, 180, 180));

#modified ADX Line
def adxlength = 10;
def adxlimit = 25;
def adxmult = 1;
def ADX = DMI(adxlength).ADX;
def line = adxlimit;
DEF ADX1 = adxmult * ((DMI(10).ADX) - adxlimit);
AddVerticalLine(ADX1 >= 1 and ADX1 < ADX1[1] and ADX1[1] > ADX1[2], "", Color.BLUE);

#Calculate Iron Rod Angle
def ir = HullMovingAvg(hlc3, slowhma);
def irg = HullMovingAvg(hlc3, fasthma);
def ira = ir - ir[anglelength];
def irga = irg - irg[anglelength];

plot IRangleline= angscalingfactor * (Round(((ATan(ira /anglelength) * 180 / Double.Pi)),1));
plot IRgangleline = angscalingfactor * (Round(((ATan(irga /anglelength) * 180 / Double.Pi)), 1));

irangleline.DefineColor("UpStrong", Color.UPTICK);
irangleline.DefineColor("weak",createColor(50,150,250));
irangleline.DefineColor("Downstrong", Color.DOWNTICK);
irangleline.AssignValueColor(if IRangleline >= minangle then irangleline.Color("upstrong") else if
IRangleline <= -minangle then irangleline.Color("downstrong") else irangleline.Color("weak"));
irangleline.setLineWeight(2);

irgangleline.DefineColor("UpStrong", Color.UPTICK);
irgangleline.DefineColor("weak",createColor(50,150,250));
irgangleline.DefineColor("Downstrong", Color.DOWNTICK);
#irgangleline.AssignValueColor(if IRgangleline >= 0 then irgangleline.Color("upstrong") else if IRgangleline < 0 then irgangleline.Color("downstrong") else irgangleline.Color("weak"));
irgangleline.AssignValueColor(if IRgangleline >= minangle then irgangleline.Color("upstrong") else if IRgangleline <= -minangle then irgangleline.Color("downstrong") else irgangleline.Color("weak"));
irgangleline.setLineWeight(3);
irgangleline.SetStyle(Curve.SHORT_DASH);

AddCloud(IRgangleline, minangle, Color.GREEN, color.light_gray);
addcloud(-minangle,irgangleline, color.red,color.light_gray);
#AddCloud(IRangleline, minangle, Color.GREEN, color.light_gray);
#addcloud(-minangle,irangleline, color.red,color.light_gray);
AddCloud(IRgangleline, 0, Color.light_GREEN, color.light_red);
#AddCloud(Irangleline, 0, Color.light_GREEN, color.light_red);


#Trend Strength (TS) indictor based on distance between hma lines
plot TS = (HullMovingAvg((AbsValue(ir - irg) *tsmult*angscalingfactor), 3)) + tsplace;
TS.SetDefaultColor(Color.BLUE);
TS.SetStyle(Curve.SHORT_DASH);
TS.SetLineWeight(2);
plot tsbase=tsplace;
tsbase.setDefaultColor(color.blue);

PLOT MID=0;
mid.SetDefaultColor(Color.black);mid.SetLineWeight(2);

#LABELS
addlabel(yes,fasthma+ "hma IronRod Angle Lower Study: ASF= "+angscalingfactor, color.black);
AddLabel(yes,fasthma+"/"+slowhma+ "hma separation- Trend Strength (TS)", Color.BLUE);

AddLabel(avgSMI >= smilimit, "Avg SMI", Color.uptick);
addlabel(avgsmi <= -smilimit, "Avg SMI", color.downtick);
addlabel(avgsmi > -smilimit and avgsmi < smilimit, "Avg SMI Chopzone", color.GRAY);

AddLabel(yes,"Minangle= "+ minangle + "deg" , Color.dark_GRAY);

addlabel(irgangleline <= -minangle,"IRguideline angle= "+ irgangleline +"deg", color.downtick);
addlabel(irgangleline >= minangle,"IRguideline angle= "+ irgangleline +"deg", color.uptick);
addlabel(irgangleline > -minangle and irangleline < minangle, "IRguideline angle= "+ irgangleline +"deg", createcolor(50,150,250));

addlabel(irangleline <= -minangle,"IR angle= "+ irangleline +"deg", color.downtick);
addlabel(irangleline >= minangle,"IR angle= "+ irangleline +"deg", color.uptick);
addlabel(irangleline > -minangle and irangleline < minangle, "IR angle= "+ irangleline +"deg",createcolor(50,150,250));

Alert(audioalarm and irgangleline >= minangle and irgangleline[1] < minangle, "Guideline above minangle", Alert.bar, Sound.ring);
Alert (audioalarm and irgangleline <= -minangle and irgangleline[1] > -minangle, "Guideline below minangle", Alert.bar, Sound.ring);

#End of Study

By the way, where is BuyLow these days?
 
Sorry I mistakingly chose quote. My screen shows as pink viewing the upper study but I do like this
 
@J007RMC You can comment-out the background color changes. I don't like them either but wanted to post unedited version the way BuyLow had it at the time.
 
@tomsk how do i insert arrows at the crossovers between SMI and AvgSMI?

I tried to edit, but failed:
# plot the Breakout Signals
plot UpSignal = if “SMI” crosses above “AvgSMI” else Double.NaN;
UpSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpSignal.HideTitle();

plot DownSignal = if “SMI” crosses below “AvgSMI” else Double.NaN;
DownSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DownSignal.HideTitle();
 
@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
 
@tomsk thanks man! is the multiplication of both [SMI * 0.996] and [AvgSMI then SMI * 1.004] needed because it needs a distinctive clearance to plot?
I forgot about the [input showBreakoutSignals = yes;]
 
@tomsk thanks man! is the multiplication of both [SMI * 0.996] and [AvgSMI then SMI * 1.004] needed because it needs a distinctive clearance to plot?
I forgot about the [input showBreakoutSignals = yes;]


@Playstation Exactly - it you don't adjust the position by that scaling factor then it would coincide with the other plots. I included it there for a cleaner visual view of the signal.
 
I am looking for one line at the bottom of this code on a 1 minute chart every time the %K crosses up thru the %D with an audio alert with a bell, chime or any sound that TOS has.....if anyone can write it I would really appreciate it...ty

Code:
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);
[CODE]
 
@Duece This should alert in both directions.
Code:
Alert(SMI1 crosses above SMI, "SMI Cross Up");
Alert(SMI1 crosses below SMI, "SMI Cross Down");
 
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
337 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