Indicator for Think or Swim based on Rob Smith's The STRAT

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;
 
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???
 
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?
 
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?
 
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);
 
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?
 
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,
 
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.
 
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.
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
333 Online
Create Post

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