• LIMITED TIME ONLY: Take $40 off VIP with code: BTD40.

Rob Smith's The STRAT Indicator for ThinkorSwim

greco26

Active member
Thank for your reply. I am not getting expected results. Live bar's low should be lower than previous bar and close should be 50% retracement of previous bar.
I've added the code to include the current bar to be lower then the previous bar.

def fiftypct = (high[1] - low[1])/2 + low[1];
plot trigger= low< low[1] and close >= fiftypct;
 

JoeSD

Member
VIP
The Pre-Loaded chart set-up - Pre-Loaded intraday chart: https://tos.mx/q7Bfm3J (Now complete with TFC study!) - won't load the candles??? The volume bars show but nothing shows on the price chart??? Any ideas?

Thanks. Joe

Can't figure out how to add a screenshot of what it looks like but it has the volume bars, but nothing in the price area???
 

ganeshinbarajan

New member
I tested for last two days. Its working perfectly. Is it possible to add line for 0% and 100% and 50 % retracement line of previous bar for any time frame?
 

Trading51

Active member
2019 Donor
Hello fellow #TheStrat-ers, I wanted to say thank you for all the hard work in this forum, especially @Pelonsax. I've used several of the scripts posted here. I wanted to add one to the mix for creating price lines for insidebars. Maybe you'll find it useful. It's my first attempt at coding anything, so...it may not be elegant, but it does the trick. It plots high/low lines after an inside candle to show where potential entry points are as well as the high/low price lines for the candle before the insidebar for potential exit points. You have to change the aggregation depending on which timeframe you're on. Hope it helps.
Ruby:
#By Jefe 10/06/2021 for #TheStrat-ers

# Draws high/low price lines for insidebars and the high/low price for the candle before the insidebar to identify possible entry/exits on insidebar patterns.
#------------------------------------
def insidebar = High < High[1] and Low > Low[1];
def price1 = ((high) and isnan(insidebar[-1]));
def price2 = ((high) and isnan(insidebar[-1]));


input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input displace2 = -2;
input displace3 = -1;

plot longin = if price1 and insidebar[1] then (high(period = aggregationperiod)[-displace]) else double.nan;
Longin.SetDefaultColor(GetColor(6));
longin.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
addchartbubble(longin, longin, longin, color.Green, No);

plot shortin = if price1 and insidebar[1] then (low(period = aggregationperiod)[-displace]) else double.nan;
shortin.SetDefaultColor(GetColor(6));
shortin.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
addchartbubble(shortin, shortin, shortin, color.Green, yes);

plot longout = if price2 and insidebar[1] then (high(period = aggregationperiod)[-displace2]) else double.nan;
Longout.SetDefaultColor(GetColor(5));
longout.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
addchartbubble(longout, longout, longout, color.red, Yes);

plot Shortout = if price2 and insidebar[1] then (low(period = aggregationperiod)[-displace2]) else double.nan;
Shortout.SetDefaultColor(GetColor(5));
Shortout.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
addchartbubble(shortout, shortout, shortout, color.red, no);

plot FiftyRetrace = if price2 and insidebar[1] then (hl2(period = aggregationperiod)[-displace3]) else double.nan;
FiftyRetrace.SetDefaultColor(GetColor(7));
FiftyRetrace.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
I see it works on the 4hour is there any required time frames needed or it can work on any time frame?
 

greco26

Active member
Please see below image, I need study to add line of high, low and 50 % of previous bar for any time frame.
This should work. I've given you the ability to turn on and off short and long setups along with what lines you want to show. I'm going to send this out on Twitter too.



Code:
##############

#SSS50PercentRule Auto Lines for TheStrat 

#Created by Tim G.
#January 14, 2022
#V_1

##############

input ShowHiLoLines = yes;
input Show50PctLine = yes;
input ShowLong = yes;
input ShowShort = yes;

def fiftypct = (high[1] - low[1])/2 + low[1];
def triggerlong= low< low[1] and close >= fiftypct;
def triggershort= high> high[1] and close <= fiftypct;

def bn1m = HighestAll(if open == open then BarNumber()-1  else Double.NaN);

#plot daylow = if BarNumber() < bn1d then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) then l1d else double.nan);

plot LSSSlow = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then low[1] else double.nan);
plot LSSShigh = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then High[1] else double.nan);
plot LSSSlow2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then low[1] else double.nan);
plot LSSShigh2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then High[1] else double.nan);
plot LSSSFifty= if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and Show50PctLine and triggerlong and showlong then fiftypct else double.nan);

LSSShigh.SetDefaultColor(Color.WHITE);
LSSShigh.SetStyle(Curve.SHORT_DASH);
LSSShigh.SetLineWeight(1);
LSSShigh2.SetDefaultColor(Color.green);
LSSShigh2.SetLineWeight(1);

LSSSFifty.SetDefaultColor(Color.WHITE);
LSSSFifty.SetStyle(Curve.SHORT_DASH);
LSSSFifty.SetLineWeight(1);


LSSSlow.SetDefaultColor(Color.WHITE);
LSSSlow.SetStyle(Curve.SHORT_DASH);
LSSSlow.SetLineWeight(1);
LSSSlow2.SetDefaultColor(Color.red);
LSSSlow2.SetLineWeight(1);

plot StSSSlow = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then low[1] else double.nan);
plot StSSShigh = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then High[1] else double.nan);
plot StSSSlow2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then low[1] else double.nan);
plot StSSShigh2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then High[1] else double.nan);
plot StSSSFifty= if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and Show50PctLine and triggershort and showshort then fiftypct else double.nan);

StSSShigh.SetDefaultColor(Color.WHITE);
StSSShigh.SetStyle(Curve.SHORT_DASH);
StSSShigh.SetLineWeight(1);
StSSShigh2.SetDefaultColor(Color.red);
StSSShigh2.SetLineWeight(1);


StSSSlow.SetDefaultColor(Color.WHITE);
StSSSlow.SetStyle(Curve.SHORT_DASH);
StSSSlow.SetLineWeight(1);
StSSSlow2.SetDefaultColor(Color.green);
StSSSlow2.SetLineWeight(1);

StSSSFifty.SetDefaultColor(Color.WHITE);
StSSSFifty.SetStyle(Curve.SHORT_DASH);
StSSSFifty.SetLineWeight(1);
 

Trading51

Active member
2019 Donor
This should work. I've given you the ability to turn on and off short and long setups along with what lines you want to show. I'm going to send this out on Twitter too.



Code:
##############

#SSS50PercentRule Auto Lines for TheStrat

#Created by Tim G.
#January 14, 2022
#V_1

##############

input ShowHiLoLines = yes;
input Show50PctLine = yes;
input ShowLong = yes;
input ShowShort = yes;

def fiftypct = (high[1] - low[1])/2 + low[1];
def triggerlong= low< low[1] and close >= fiftypct;
def triggershort= high> high[1] and close <= fiftypct;

def bn1m = HighestAll(if open == open then BarNumber()-1  else Double.NaN);

#plot daylow = if BarNumber() < bn1d then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) then l1d else double.nan);

plot LSSSlow = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then low[1] else double.nan);
plot LSSShigh = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then High[1] else double.nan);
plot LSSSlow2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then low[1] else double.nan);
plot LSSShigh2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then High[1] else double.nan);
plot LSSSFifty= if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and Show50PctLine and triggerlong and showlong then fiftypct else double.nan);

LSSShigh.SetDefaultColor(Color.WHITE);
LSSShigh.SetStyle(Curve.SHORT_DASH);
LSSShigh.SetLineWeight(1);
LSSShigh2.SetDefaultColor(Color.green);
LSSShigh2.SetLineWeight(1);

LSSSFifty.SetDefaultColor(Color.WHITE);
LSSSFifty.SetStyle(Curve.SHORT_DASH);
LSSSFifty.SetLineWeight(1);


LSSSlow.SetDefaultColor(Color.WHITE);
LSSSlow.SetStyle(Curve.SHORT_DASH);
LSSSlow.SetLineWeight(1);
LSSSlow2.SetDefaultColor(Color.red);
LSSSlow2.SetLineWeight(1);

plot StSSSlow = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then low[1] else double.nan);
plot StSSShigh = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then High[1] else double.nan);
plot StSSSlow2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then low[1] else double.nan);
plot StSSShigh2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then High[1] else double.nan);
plot StSSSFifty= if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and Show50PctLine and triggershort and showshort then fiftypct else double.nan);

StSSShigh.SetDefaultColor(Color.WHITE);
StSSShigh.SetStyle(Curve.SHORT_DASH);
StSSShigh.SetLineWeight(1);
StSSShigh2.SetDefaultColor(Color.red);
StSSShigh2.SetLineWeight(1);


StSSSlow.SetDefaultColor(Color.WHITE);
StSSSlow.SetStyle(Curve.SHORT_DASH);
StSSSlow.SetLineWeight(1);
StSSSlow2.SetDefaultColor(Color.green);
StSSSlow2.SetLineWeight(1);

StSSSFifty.SetDefaultColor(Color.WHITE);
StSSSFifty.SetStyle(Curve.SHORT_DASH);
StSSSFifty.SetLineWeight(1);
does it only work on certain time frames or under certain conditions, I have it on a 15 min and it doesn't work?
 

Trading51

Active member
2019 Donor
Screenshot_2022-01-14_161436.png
It is not working

It is not working as expected. Please check the screenshot. It is not picking previous bar. I tried in daily timeframe. I dont' see any line for some other tickers.
It can work on the Globex session for the 4 hour,
 

ganeshinbarajan

New member
This should work. I've given you the ability to turn on and off short and long setups along with what lines you want to show. I'm going to send this out on Twitter too.



Code:
##############

#SSS50PercentRule Auto Lines for TheStrat

#Created by Tim G.
#January 14, 2022
#V_1

##############

input ShowHiLoLines = yes;
input Show50PctLine = yes;
input ShowLong = yes;
input ShowShort = yes;

def fiftypct = (high[1] - low[1])/2 + low[1];
def triggerlong= low< low[1] and close >= fiftypct;
def triggershort= high> high[1] and close <= fiftypct;

def bn1m = HighestAll(if open == open then BarNumber()-1  else Double.NaN);

#plot daylow = if BarNumber() < bn1d then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) then l1d else double.nan);

plot LSSSlow = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then low[1] else double.nan);
plot LSSShigh = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then High[1] else double.nan);
plot LSSSlow2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then low[1] else double.nan);
plot LSSShigh2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showlong and triggerlong and ShowHiLoLines then High[1] else double.nan);
plot LSSSFifty= if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and Show50PctLine and triggerlong and showlong then fiftypct else double.nan);

LSSShigh.SetDefaultColor(Color.WHITE);
LSSShigh.SetStyle(Curve.SHORT_DASH);
LSSShigh.SetLineWeight(1);
LSSShigh2.SetDefaultColor(Color.green);
LSSShigh2.SetLineWeight(1);

LSSSFifty.SetDefaultColor(Color.WHITE);
LSSSFifty.SetStyle(Curve.SHORT_DASH);
LSSSFifty.SetLineWeight(1);


LSSSlow.SetDefaultColor(Color.WHITE);
LSSSlow.SetStyle(Curve.SHORT_DASH);
LSSSlow.SetLineWeight(1);
LSSSlow2.SetDefaultColor(Color.red);
LSSSlow2.SetLineWeight(1);

plot StSSSlow = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then low[1] else double.nan);
plot StSSShigh = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then High[1] else double.nan);
plot StSSSlow2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then low[1] else double.nan);
plot StSSShigh2 = if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and showshort and triggershort and ShowHiLoLines then High[1] else double.nan);
plot StSSSFifty= if BarNumber() < bn1m then Double.NaN else HighestAll( if (!IsNaN(close) and IsNaN(close[-1])) and Show50PctLine and triggershort and showshort then fiftypct else double.nan);

StSSShigh.SetDefaultColor(Color.WHITE);
StSSShigh.SetStyle(Curve.SHORT_DASH);
StSSShigh.SetLineWeight(1);
StSSShigh2.SetDefaultColor(Color.red);
StSSShigh2.SetLineWeight(1);


StSSSlow.SetDefaultColor(Color.WHITE);
StSSSlow.SetStyle(Curve.SHORT_DASH);
StSSSlow.SetLineWeight(1);
StSSSlow2.SetDefaultColor(Color.green);
StSSSlow2.SetLineWeight(1);

StSSSFifty.SetDefaultColor(Color.WHITE);
StSSSFifty.SetStyle(Curve.SHORT_DASH);
StSSSFifty.SetLineWeight(1);
It is working perfectly after I reset all my studies. Thank you so much. I added this indicator in all of my timeframe. This is one of best indicator I ever have.
 

greco26

Active member
I see it works on the 4hour is there any required time frames needed or it can work on any time frame?
It might not work for after hours charts because of some code I used to limit the length of the lines. Besides that, it should work on any Ruth timeframe.
 

JoeSD

Member
VIP
It has to meet the sss 50% rule either long or short otherwise no lines will plot.
Greco26,

thanks for your work on this. :).

Just so I have it clear, per Sarah's rules, this will only show when there is a #3 Candle (Outside bar) that has just closed, and then for the NEXT bar will plot the high, the low, and the 50% of the #3 Outside bar correct?
 

Similar threads

Top