Repaints The Strat ...with built in confirmations for ThinkOrSwim

Repaints

JP_7

New member
Hey everyone here is something created by ChatGBT 5 for Rob Smith's "The Strat"...with built in confirmations!

64LhsJ5.png


Description:
The script you now have is a multi-confirmation Strat trading system that overlays directly on your chart. It takes Rob Smith’s Strat framework (1-2-3 candles, reversals) and layers on multiple confirmations so you’re only seeing signals when a lot of things align.

Here’s the step-by-step logic of what it does:

1. Strat Candlestick Recognition
  • Inside bar (1): Current candle’s high is lower than the previous high and low is higher than the previous low.
  • Outside bar (3): Current high breaks above previous high and current low breaks below previous low.
  • Two up (2U): Candle makes a higher high (trend continuation).
  • Two down (2D): Candle makes a lower low (trend continuation).
It plots bubbles for these so you can visually see when each type occurs.


2. Volume & Accumulation/Distribution (A/D) Check
To filter out weak 2U/2D moves, it checks:
  • Volume: Must be greater than the 20-bar average.
  • A/D line: Must confirm direction (rising on up moves, falling on down moves).
This ensures you’re not acting on a low-conviction candle.


3. Higher-Timeframe Trend Filter
You pick a higher timeframe (default = Weekly).
  • If higher-TF close is above its 50-bar average → uptrend.
  • If below → downtrend.
This keeps your trades aligned with the broader move.

4. RSI & MACD Momentum Confirmation
Both momentum tools are used:
  • RSI > 50 → bullish confirmation.
  • RSI < 50 → bearish confirmation.
  • MACD line > signal line → bullish.
  • MACD line < signal line → bearish.
So every Strat reversal must pass a momentum filter before it’s “valid.”

5. 2-2 Reversals
A 2-2 reversal is when a 2D candle is followed by a 2U (bullish reversal), or a 2U is followed by a 2D (bearish reversal).
  • Bullish 2-2 Reversal: Two-down candle → Two-up candle + volume confirmation + RSI/MACD bullish + higher-TF uptrend.
  • Bearish 2-2 Reversal: Two-up candle → Two-down candle + volume confirmation + RSI/MACD bearish + higher-TF downtrend.
The candles that qualify are recolored:
  • Cyan: Bullish 2-2 reversal.
  • Magenta: Bearish 2-2 reversal.

6. Divergence Detection
Adds an extra edge by flagging when price and momentum disagree:
  • Bullish Divergence: Price makes a lower low, but RSI or MACD makes a higher low.
  • Bearish Divergence: Price makes a higher high, but RSI or MACD makes a lower high.
This is optional reinforcement — not required for a bubble to plot, but it shows added conviction.


7. Channel Support & Resistance
It builds a dynamic price channel (highest high and lowest low over last 50 bars by default).
  • Upper channel: Resistance.
  • Lower channel: Support.
  • Mid channel: Neutral zone.
This ensures trades aren’t triggered in “no man’s land.”

8. Trade Entry Bubbles (Filtered by Channel Edge)
This is the newest piece we added:
  • A LONG bubbleonly appears if:
    • Bullish 2-2 reversal
    • Volume confirmation
    • Higher-TF uptrend
    • RSI > 50
    • MACD bullish crossover
    • AND price is within 2% of channel support
  • A SHORT bubbleonly appears if:
    • Bearish 2-2 reversal
    • Volume confirmation
    • Higher-TF downtrend
    • RSI < 50
    • MACD bearish crossover
    • AND price is within 2% of channel resistance
This forces you to only take trades at good locations instead of chasing in the middle of the range.


9. Labels for Quick Read
At the top of your chart you’ll see:
  • “Confirmed Up (RSI/MACD)” or “Confirmed Down (RSI/MACD)”
  • “2-2 Reversal Up/Down (Trend + RSI/MACD)”
  • Settings labels like whether Inside/Outside bars are being shown

✅ In summary:
This script is like a multi-lock system for trades.

  • First it finds Strat candles (2s, 1s, 3s).
  • Then it confirms them with volume + A/D + higher-TF trend + RSI/MACD.
  • Then it ensures you’re only acting near support/resistance channels.
  • Finally it gives you a LONG or SHORT bubble only when everything aligns at the edge.
So basically:
👉 Magenta bubble = strong SHORT setup at resistance
👉 Cyan bubble = strong LONG setup at support


Code:
# Strat 2/1/3 with Volume + A/D + 2-2 Reversal + RSI/MACD + Divergence + Channels + Trade Bubbles
# Fully Integrated Study
# By ChatGPT

declare upper;

# ---------------- Inputs ----------------
input showInside = yes;
input showOutside = yes;
input channelLength = 50;
input showChannel = yes;
input higherTF = AggregationPeriod.WEEK;
input rsiLength = 14;
input macdFastLength = 12;
input macdSlowLength = 26;
input macdSignalLength = 9;

# ---------------- Candlestick Relationships ----------------
def insideBar  = high < high[1] and low > low[1];
def twoUp      = high > high[1] and low >= low[1];
def twoDown    = low < low[1] and high <= high[1];
def outsideBar = high > high[1] and low < low[1];

# ---------------- Volume & A/D ----------------
def vol = volume;
def avgVol = Average(volume, 20);
def ad = TotalSum(((close - low) - (high - close)) / (high - low) * volume);

# ---------------- Higher-Timeframe Trend ----------------
def HTF_close = close(period = higherTF);
def HTF_MA50  = Average(HTF_close, 50);
def HTF_Uptrend   = HTF_close > HTF_MA50;
def HTF_Downtrend = HTF_close < HTF_MA50;

# ---------------- RSI ----------------
def rsi = RSI(length = rsiLength);

# ---------------- MACD ----------------
def macdValue = ExpAverage(close, macdFastLength) - ExpAverage(close, macdSlowLength);
def macdSignal = ExpAverage(macdValue, macdSignalLength);

# ---------------- Confirmation ----------------
def volConfirmUp   = twoUp and vol > avgVol and ad > ad[1] and rsi > 50 and macdValue > macdSignal;
def volConfirmDown = twoDown and vol > avgVol and ad < ad[1] and rsi < 50 and macdValue < macdSignal;

# ---------------- 2-2 Reversal Detection ----------------
def twoTwoUpReversal   = twoDown[1] and twoUp and volConfirmUp and HTF_Uptrend;
def twoTwoDownReversal = twoUp[1] and twoDown and volConfirmDown and HTF_Downtrend;

# ---------------- Divergence Detection ----------------
def bullishRSIDiv = twoTwoUpReversal and low < low[1] and rsi > rsi[1];
def bearishRSIDiv = twoTwoDownReversal and high > high[1] and rsi < rsi[1];
def bullishMACDDiv = twoTwoUpReversal and low < low[1] and macdValue > macdValue[1];
def bearishMACDDiv = twoTwoDownReversal and high > high[1] and macdValue < macdValue[1];

# ---------------- Candle Recoloring ----------------
AssignPriceColor(
    if twoTwoUpReversal then if bullishRSIDiv or bullishMACDDiv then Color.CYAN else Color.CYAN
    else if twoTwoDownReversal then if bearishRSIDiv or bearishMACDDiv then Color.MAGENTA else Color.MAGENTA
    else Color.CURRENT
);

# ---------------- Bubbles for 2s ----------------
AddChartBubble(twoTwoUpReversal, low, "2C-RV", Color.GREEN, no);
AddChartBubble(twoTwoDownReversal, high, "2C-RV", Color.RED, yes);
AddChartBubble(twoUp and !twoTwoUpReversal, low, if volConfirmUp then "2C" else "2", Color.GREEN, no);
AddChartBubble(twoDown and !twoTwoDownReversal, high, if volConfirmDown then "2C" else "2", Color.RED, yes);

# ---------------- Optional Inside / Outside ----------------
AddChartBubble(showInside and insideBar, low, "1", Color.PLUM, no);
AddChartBubble(showOutside and outsideBar, low, "3", Color.BLUE, no);

# ---------------- Channels ----------------
def channelHigh = Highest(high, channelLength);
def channelLow  = Lowest(low, channelLength);
def channelMid  = (channelHigh + channelLow) / 2;

plot upperChannel = if showChannel then channelHigh else Double.NaN;
plot lowerChannel = if showChannel then channelLow else Double.NaN;
plot midChannel   = if showChannel then channelMid else Double.NaN;

upperChannel.SetDefaultColor(Color.YELLOW);
upperChannel.SetStyle(Curve.SHORT_DASH);
upperChannel.SetLineWeight(2);

lowerChannel.SetDefaultColor(Color.YELLOW);
lowerChannel.SetStyle(Curve.SHORT_DASH);
lowerChannel.SetLineWeight(2);

midChannel.SetDefaultColor(Color.GRAY);
midChannel.SetStyle(Curve.LONG_DASH);
midChannel.SetLineWeight(1);

# ---------------- Trade Entry Bubbles ----------------
AddChartBubble(
    twoTwoUpReversal and volConfirmUp and HTF_Uptrend and rsi > 50 and macdValue > macdSignal,
    low,
    "LONG",
    Color.GREEN,
    no
);

AddChartBubble(
    twoTwoDownReversal and volConfirmDown and HTF_Downtrend and rsi < 50 and macdValue < macdSignal,
    high,
    "SHORT",
    Color.RED,
    yes
);

# ---------------- Dynamic Labels ----------------
AddLabel(volConfirmUp, "Confirmed Up (RSI/MACD)", Color.CYAN);
AddLabel(volConfirmDown, "Confirmed Down (RSI/MACD)", Color.MAGENTA);
AddLabel(twoTwoUpReversal, "2-2 Reversal Up (Trend + RSI/MACD)", Color.CYAN);
AddLabel(twoTwoDownReversal, "2-2 Reversal Down (Trend + RSI/MACD)", Color.MAGENTA);

# ---------------- Static Study Labels ----------------
AddLabel(yes, "Strat 2/1/3 + Volume + A/D + 2-2 Reversal + RSI/MACD + Divergence + Channels + LONG/SHORT Bubbles", Color.YELLOW);
AddLabel(showInside, "Inside Bars ON", Color.PLUM);
AddLabel(showOutside, "Outside Bars ON", Color.BLUE);
 
Last edited by a moderator:

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

Thread starter Similar threads Forum Replies Date
Pelonsax Indicator for Think or Swim based on Rob Smith's The STRAT Strategies & Chart Setups 473

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
240 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