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

I found this script for adding a custom watchlist column and it works fine for 15m and 30m. But it is not displaying correctly for 1h, nor 4h. I am sure it has to do with the aggregation periods not starting at market open. How do I force them to aggregate at market open?

The short answer:

Try this:

Chart Settings > Equities > Axis > Time
Unchecked =
Show Extended-hours Trading Session
Checked = Start aggregations at market open

2PlrwXz.png


The long answer:

Under Chart Settings for Equities, "Start aggregations at market open" appears to be impacted by whether or not Show Extended-hours Trading Session is turned on also.

Where the 1 hour and 4 hour candles start is impacted by two settings: Start aggregations at market open and Show Extended-Hours Trading session. Based on experiments shown below, Start aggregations at market open only works if Show Extended-Hours Trading session is UNCHECKED.

Option 1: Hourly candle start at 8:30
UNCHECK "Show Extended-Hours Trading session"
CHECK "Start aggregations at market open"


2PlrwXz.png


Notice Agilent open on 2021, October 1st = 157.15, and the hour chart started at 8:30 AM!

Ba3yPN3.png


Option 2: Hourly Candle start at 8:00
CHECK "Show Extended-Hours Trading session"
CHECK "Start aggregations at market open"


Sg8h6q7.png


Notice Agilent open on 2021, October 1st = 157.22, and the hour chart started at 8:00 AM!

I3TBpmv.png


Option 3: Hourly candle starts at 8:00
CHECK "Show Extended-Hours Trading session"
UNCHECK "Start aggregations at market open"


IuhlYct.png


Notice Agilent open on 2021, October 1st = 157.22, and the hour chart started at 8:00 AM!

I3TBpmv.png


Option 4: Hourly candle start at 8:00
UNCHECK "Show Extended-Hours Trading session"
UNCHECK "Start aggregations at market open"


23vAdAK.png


Notice Agilent open on 2021, October 1st = 157.22, and the hour chart started at 8:00 AM!

I3TBpmv.png
 
have you tried a strat that sets up both long and short position triggers on both sides of these trades? curious if that has worked for you / anyone with The Strat.
Me personally? No. It doesn't for me, since my method is to look for entries on a lower time frame that are in agreement with a higher time frame trend. So if I flipped my entry, I'd actually be trading against my own system (and I haven't tested this, so I don't want to put any money into that idea.)

Another thing: my entries are usually towards a reversal target, whereas if I traded opposite of my reversal target, I'd be trading a continuation, which would have only an "estimated" target, and there wouldn't be a stop to hunt for (some people call theStrat stop-hunting because it goes after obvious pivots).

That's not to say it wont' work. I have seen postings on Twitter about automated trading of theStrat. You could probably do it in ThinkOrSwim to a lesser extent by pasting in a conditional order template, since the bulk of #theStrat is comparisons of candle highs and lows.
 
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);
 
Last edited by a moderator:
I am using STRAT BAR NUMBERS 2.0, posted on Page 1 (Link https://tos.mx/Kac4tLf). Is it possible to add a portion of code that would draw two lines: 1) a line from the high of the 1 bar (inside bar) to the high of the next 3 bar (outside bar) and then extend past that point until the next 1 (inside) bar is formed? 2) line from the low of the 1 bar (inside bar) to the low of the next 3 bar (outside bar) and then extend past that point until the next 1 (inside) bar is formed? These are not necessarily consecutive 1-3; in fact, it is possibly better to have some distance between. Together should form a megaphone / expanding range pattern. It may need an option to show most recent only versus show all if too congested.
 
Last edited:
The numbers are annoying. Can't someone color code that? It may end the confusion between up and down candlesticks and the Strat
 
The numbers are annoying. Can't someone color code that? It may end the confusion between up and down candlesticks and the Strat

Since the 2s are the only directional candles in #theStrat, maybe they're the source of confusion?
When I first learned candlesticks, UP = anything with close > open (anything green), and DOWN = anything red with close < open.

By contrast, #theStrat looks at whether the candle exceeded the prior candle to the upside (2UP) or downside (2DOWN) or both sides (3) or neither side (1).

I did this to keep it straight for myself, when first starting:

2 UP = GREEN 2, ABOVE the candle
2 DOWN = RED 2, BELOW the candle

gzpjTKw.png


Code:
def insideBar = high <= high[1] and low >= low[1];
def outsideBar = high > high[1] and low < low[1];
def upBar = high > high[1] and low >= low[1];
def downBar = low < low[1] and high <= high[1];
plot barType = 
if      insideBar  then 1 
else if outsideBar then 3 
else double.NaN;
barType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
barType.AssignValueColor(Color.White);
plot upType = if upBar then 2 else double.NaN;
upType.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
upType.AssignValueColor(Color.Green);
plot downType = if downBar then 2 else double.NaN;
downType.AssignValueColor(Color.Red);
downType.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);

If this isn't sufficient, as @MerryDay stated, might need some more details to get an idea of what you want.
 
I added code to the top post for expanded STRAT bar watchlist columns that now show the current bar (in brackets) on each time frame and the last two bars before that. They are color coded to include reversals. Here's what they look like. Other than cyan or magenta for reversals, the color is based on the current bar.
JXfTMz6.png
i finally got ur code up for my watchlist but I am still confused on the other colors that arent magenta or cyan (light green dark green etc)
 
i finally got ur code up for my watchlist but I am still confused on the other colors that arent magenta or cyan (light green dark green etc)
twoup then color.green else if
twodown then color.red else if
outsidebarup then color.dark_green else if
insidebarup then color.light_green else if
outsidebardown then color.dark_red else if
insidebardown then color.orange else if
!insidebarup and
!insidebardown and
insidebar then color.white else if
!outsidebardown and
!outsidebarup and
outsidebar then color.white else color.current);
 
Anyone know if there is a code for an alert on the strat indicator itself, that will give an audio and visual alert when the color of the number 2 above or below the last closed candle is different than the color of the base 2 candle itself? I have looked for this but not having any luck. Thanks for any help.
 
Last edited:
Hello! Thank you creating all of these wonderful scripts! I did have a question about an error I am seeing on the "New Watchlist Column" scripts. They are incredibly handy to get an overview of the current strat position for a watchlist, but I am seeing an issue when I added a column for the hourly candles. The watchlist column is reading the current hourly candle as a 2D, but when I look at it on the chat it is a 1. Oddly this error is not consistent for all tickers in this watchlist.

I checked the script and I DO NOT have include extended-hours trading selected on the hourly column and I do not have extended hours on my chart. HOWEVER - just to check if that was causing an issue, I turned on extended hours on my chart and then the candles looked identical to how they are labeled in the watchlist.

Does anyone know how to fix this issue? I know that the Start only focuses on candles formed during trading hour and not AH or PM.

Sorry if you already answered this question.

Thank you!
 
Last edited:
Has anyone done a script to scan for Sara Strat Sniper's 50% rule?
Identifies candles that have gone Scenario 2 in one direction and then retraced at least 50% of the range of the previous candle?
 
I am using STRAT BAR NUMBERS 2.0, posted on Page 1 (Link https://tos.mx/Kac4tLf). Is it possible to add a portion of code that would draw two lines: 1) a line from the high of the 1 bar (inside bar) to the high of the next 3 bar (outside bar) and then extend past that point until the next 1 (inside) bar is formed? 2) line from the low of the 1 bar (inside bar) to the low of the next 3 bar (outside bar) and then extend past that point until the next 1 (inside) bar is formed? These are not necessarily consecutive 1-3; in fact, it is possibly better to have some distance between. Together should form a megaphone / expanding range pattern. It may need an option to show most recent only versus show all if too congested.
AlphaOptions, try this script. It doesn't connect the ones as you requested but it does connect swing highs and lows so it's pretty close to what your asking for. It's a very handy tool.
Ruby:
# May 27 2012 - FractalTrader
#
#This script will show support and resistance lines based on either
# user-defined price pivots, or automatically based on pivot points
# calculated by the script. In the case of automatic determination, only
# the last two matching points are used.
#hint numBars: For automatic pivot calculation: How many bars to use in calculation of pivotPoints. ie. current high is higher than both prior X bars and following X bars
#hint showLines: Show a line extending from high and low price pivots
#hint showValues: Show the numeric value of price occurring at the pivot point
#hint showBarNumbers: For manually entered pivots: used to determine bar numbers for two price pivot points to connect. It is recommended to temporarily turn off showValues.
#hint TrendResistanceStart: Starting point of a resistance trend line (connecting the highs), entered as a bar number. It is recommended to turn on showBarNumbers temporarily to determine the value.
#hint TrendResistanceEnd: Ending point of a resistance trend line, entered as a bar number. It is recommended to turn on showBarNumbers temporarily to determine the value.
#hint TrendSupportStart: Starting point of a support trend line (connecting the lows), entered as a bar number. It is recommended to turn on showBarNumbers temporarily to determine the value.
#hint TrendSupportEnd: Ending Point of a support trend line (connecting the lows), entered as a bar number. It is recommended to turn on showBarNumbers temporarily to determine the value.
input numBars = 5;
input showLines = yes;
input showValues = yes;
input showBarNumbers = no;
input TrendResistanceStart = 0;
input TrendResistanceEnd = 0;
input TrendSupportStart = 0;
input TrendSupportEnd = 0;

def UserSetResistance = TrendResistanceStart > 0 and TrendResistanceEnd > 0;
def UserSetSupport = TrendSupportStart > 0 and TrendSupportEnd > 0;
def currentHigh = high;
def currentLow = low;
def currentBar = BarNumber();
def PH;
def PL;
def isHigherThanNextBars = fold i = 1 to numBars + 1 with p = 1
while p do currentHigh > GetValue(high, -i);
PH = if UserSetResistance and ( currentBar == TrendResistanceStart or currentBar == TrendResistanceEnd ) then currentHigh else if !UserSetResistance and (currentBar > numBars and currentHigh == Highest(currentHigh, numBars) and isHigherThanNextBars) then currentHigh else Double.NaN;
def isLowerThanNextBars = fold j = 1 to numBars + 1 with q = 1
while q do currentLow < GetValue(low, -j);
PL = if UserSetSupport and ( currentBar == TrendSupportStart or currentBar == TrendSupportEnd ) then currentLow else if !UserSetSupport and (currentBar > numBars and currentLow == Lowest(currentLow, numBars) and isLowerThanNextBars) then currentLow else Double.NaN;
rec PHBar = if UserSetResistance then TrendResistanceEnd else if !IsNaN(PH) then currentBar else PHBar[1];
rec PLBar = if UserSetSupport then TrendSupportEnd else if !IsNaN(PL) then currentBar else PLBar[1];
rec PHL = if !IsNaN(PH) then PH else PHL[1];
rec priorPHBar = if UserSetResistance then TrendResistanceStart else if PHL != PHL[1] then PHBar[1] else priorPHBar[1];
rec PLL = if !IsNaN(PL) then PL else PLL[1];
rec priorPLBar = if UserSetSupport then TrendSupportStart else if PLL != PLL[1] then PLBar[1] else priorPLBar[1];
def isFinalTwoHighPivots = currentBar >= HighestAll(priorPHBar);
def isFinalTwoLowPivots = currentBar >= HighestAll(priorPLBar);
def ResistanceFinishOffset = if isFinalTwoHighPivots then currentBar - PHBar else 0;
def ResistanceStartOffset = if isFinalTwoHighPivots then currentBar - priorPHBar else 0;
def ResistanceSlope = (GetValue(PH, ResistanceFinishOffset) - GetValue(PH, ResistanceStartOffset)) / (PHBar - priorPHBar);
def SupportFinishOffset = if isFinalTwoLowPivots then currentBar - PLBar else 0;
def SupportStartOffset = if isFinalTwoLowPivots then currentBar - priorPLBar else 0;
def SupportSlope = (GetValue(PL, SupportFinishOffset) - GetValue(PL, SupportStartOffset)) / (PLBar - priorPLBar);
rec ResistanceExtend = if currentBar == HighestAll(PHBar) then 1 else ResistanceExtend[1];
rec SupportExtend = if currentBar == HighestAll(PLBar) then 1 else SupportExtend[1];

plot pivotHigh = if
#isFinalTwoHighPivots
ph>0 then PH else Double.NaN;
plot pivotHighLine = if PHL > 0 and isFinalTwoHighPivots then PHL else Double.NaN;

plot ResistanceLine = pivotHigh;
plot ResistanceExtension = if ResistanceExtend then (currentBar - PHBar) * ResistanceSlope + PHL else Double.NaN;
plot pivotLow = if
#isFinalTwoLowPivots
pl>0 then PL else Double.NaN;
plot pivotLowLine = if PLL > 0 and isFinalTwoLowPivots then PLL else Double.NaN;
plot SupportLine = pivotLow;
plot SupportExtension = if SupportExtend then (currentBar - PLBar) * SupportSlope + PLL else Double.NaN;
plot BN = currentBar;
plot PivotDot = if !IsNaN(pivotHigh) then pivotHigh else if !IsNaN(pivotLow) then pivotLow else Double.NaN;
plot BisectLine = if !isNaN(pivotHigh) then pivotHigh else if !isNaN(pivotLow) then pivotLow else double.NaN;
pivotHigh.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
pivotHigh.SetHiding(!showValues);
pivotLow.SetDefaultColor(GetColor(4));
pivotLow.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
pivotLow.SetHiding(!showValues);
ResistanceLine.EnableApproximation();
ResistanceLine.SetDefaultColor(GetColor(7));
ResistanceLine.SetStyle(Curve.SHORT_DASH);
ResistanceExtension.SetStyle(Curve.SHORT_DASH);
ResistanceExtension.SetDefaultColor(GetColor(7));
SupportLine.EnableApproximation();
SupportLine.SetDefaultColor(GetColor(7));
SupportLine.SetStyle(Curve.SHORT_DASH);
SupportExtension.SetDefaultColor(GetColor(7));
SupportExtension.SetStyle(Curve.SHORT_DASH);
pivotHighLine.SetPaintingStrategy(PaintingStrategy.DASHES);
pivotHighLine.SetHiding(!showLines);
pivotLowLine.SetPaintingStrategy(PaintingStrategy.DASHES);
pivotLowLine.SetHiding(!showLines);
BisectLine.EnableApproximation();
BisectLine.SetLineWeight(2);
PivotDot.SetDefaultColor(GetColor(7));
PivotDot.SetPaintingStrategy(PaintingStrategy.POINTS);
PivotDot.SetLineWeight(3);
BN.SetDefaultColor(GetColor(0));
BN.SetHiding(!showBarNumbers);
BN.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
 
Last edited by a moderator:
@AlphaOptions @airgb
No, the indicator is offered as is...
I have tried to bring the Alerts and Actionable singles over from the REMIX version to the STRAT NUMBERS version 2.0 but even with most of the definitions added I still cannot get any to work on V2.0. I really do not want all these alerts and singles on that version anyway. All I really want is an audio alert that the 2 number color is different than the candle it represents when the candle closes. Example, green candle red 2 or red candle green 2. Can anyone out there help me out with this?
 
Is there a scanner out there for Inside Bars? Basically 2/1 or 3 setup.
LoK5ZMY.png
This is rather simple to accomplish in the ToS candlestick pattern editor. You can use the graphical interface and don't even need to know how to script. This is a basic inside bar search. you can also create 3-1 or 2-1 patterns. You then use the scanner and add the pattern as a search criteria.
Screen-Shot-2021-12-08-at-6-54-31-PM.png
 

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
231 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