Markov Candle Prediction For ThinkOrSwim

What pattern(settings) should be used for Mega stocks? Thank you
Human pattern recognition is powerful but also highly prone to false positives. In markets, this is often called "apophenia" — seeing meaningful signals in noise. Institutions know this risk and instead rely on statistically testable patterns with repeatable edge.
Here are the go-to patterns and models institutional and quant traders favor, ranked by statistical robustness:
Statistically Reliable Patterns Used by Institutions

1. Mean Reversion Around VWAP / Moving Averages
  • Used by: Market makers, HFTs, intraday funds
  • Tools: VWAP, standard deviation bands (like Bollinger), regression channels
  • Why: VWAP reflects where large volume has traded — price reversion to VWAP often happens due to institutional anchoring.
  • Statistical Model: Ornstein-Uhlenbeck processes (stochastic mean-reverting)
  • (e.g., RSI, Bollinger Bands, Stochastics)
2. Breakouts from Consolidation Zones
  • Used by: Trend followers, volatility traders
  • Statistical basis:
    • Low volatility regimes often precede high volatility
    • Tested using ATR squeeze, Keltner vs. Bollinger bandwidth
  • Quant Confirmation: Price > range high + increased volume + volatility expansion
  • Popular Tools: Donchian channels, Keltner, ADX, ATR ramps
  • Bollinger Band Width, ADX- Volume Spike, TTM Squeeze- Momentum, RSI, VWAP - Supply and demand zones, Price closes outside range
3. Momentum with Confirmation
  • Used by: Quant equity, macro funds
  • Core principle: Assets that perform well continue to outperform (short-term or medium-term)
  • Quant version:
    • RSI > 70 + slope positive
    • Price > 20d MA & 50d MA, rising
  • Key Add-on: Volume confirmation or price persistence
Signal TypeMomentum IndicatorConfirmation Pair
Trend + MomentumMACDADX > 20
Breakout MomentumRSI > 60Volume Spike + OBV↑
Acceleration CheckROCBollinger Band Width↑
Pullback EntryStoch RSI Cross↑Price > 21 EMA


4. Divergence in Price vs. Momentum
  • Used by: Discretionary institutional traders, macro traders
  • Statistical type: Leading indicator of exhaustion
  • Best used with:
    • RSI or ROC vs price
    • Volume divergence (OBV flat/down while price rises)
  • Caveat: Best in combination with range-bound or mean-reverting conditions
  • Recommended Setup for Divergence Detection
    Combine 1 or 2 momentum indicators with simple price structure tools:
    • RSI + MACD Histogram
    • ROC + Trendlines
    • AO + Price Swings
    • Stoch RSI + Support/Resistance
5. Order Flow Imbalances
  • Used by: High-frequency trading, execution algos
  • Concept: Institutional traders watch limit order book flow → imbalance leads price
  • Data Required: Level 2, DOM
  • Quant Proxy: Tick imbalance, delta (buy vs. sell pressure), CVD (cumulative volume delta)
  • Volume Profile indicator, Delta Volume/Bid-Ask Deltas, Cumulative Delta, VWAP & Standard Deviations and Market Structure with Volume Surge
6. Volatility Expansion / Compression
  • Used by: Options desks, gamma scalpers
  • Quant tool:
    • IV Rank/Percentile
    • HV vs. IV comparison
    • Bollinger Band width
  • Why it works: Options are priced on expected volatility. When reality diverges from pricing, opportunity arises.
Bonus: Repeated Institutional “Footprint” Patterns
These aren’t shapes like “cup and handle” — they are conditions that often signal institutional behavior:

Pattern ConditionImplication
Price flat, volume risingAccumulation or distribution
Sharp drop, no volumeLack of conviction / likely bounce
High OI + gamma at strikeOption dealer positioning
Multiple failed breakoutsLiquidity hunt / stop runs

So what should you look for?
If you want to think like an institution, prioritize conditions, not shapes.

Instead of:​

  • “I think this is a head and shoulders”, Think:
    • “Price is failing to make higher highs while RSI is fading and volume is declining — that’s a statistically testable reversal setup.”
 
Last edited by a moderator:

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

i don't know what to make of this. how would you change the settings for an ETF like TQQQ, for instance, and a daily time preference instead of 5m and the like?
This is a Probability pattern matching system. The best way to use it it to keep that defaults and then move down to a timeframe that has at least 30 matches. So for TQQQ it looks like you can use the 15 min or lower. This indicator is better for trying to trade stocks or index that have ZeroDTE options . On a 15 min chart you should get a high pattern match and then make a short term option play . Without a high number of matches this is a useless indicator!
 
Human pattern recognition is powerful but also highly prone to false positives. In markets, this is often called "apophenia" — seeing meaningful signals in noise. Institutions know this risk and instead rely on statistically testable patterns with repeatable edge.
Here are the go-to patterns and models institutional and quant traders favor, ranked by statistical robustness:
Statistically Reliable Patterns Used by Institutions

1. Mean Reversion Around VWAP / Moving Averages
  • Used by: Market makers, HFTs, intraday funds
  • Tools: VWAP, standard deviation bands (like Bollinger), regression channels
  • Why: VWAP reflects where large volume has traded — price reversion to VWAP often happens due to institutional anchoring.
  • Statistical Model: Ornstein-Uhlenbeck processes (stochastic mean-reverting)
  • (e.g., RSI, Bollinger Bands, Stochastics)
2. Breakouts from Consolidation Zones
  • Used by: Trend followers, volatility traders
  • Statistical basis:
    • Low volatility regimes often precede high volatility
    • Tested using ATR squeeze, Keltner vs. Bollinger bandwidth
  • Quant Confirmation: Price > range high + increased volume + volatility expansion
  • Popular Tools: Donchian channels, Keltner, ADX, ATR ramps
  • Bollinger Band Width, ADX- Volume Spike, TTM Squeeze- Momentum, RSI, VWAP - Supply and demand zones, Price closes outside range
3. Momentum with Confirmation
  • Used by: Quant equity, macro funds
  • Core principle: Assets that perform well continue to outperform (short-term or medium-term)
  • Quant version:
    • RSI > 70 + slope positive
    • Price > 20d MA & 50d MA, rising
  • Key Add-on: Volume confirmation or price persistence
Signal TypeMomentum IndicatorConfirmation Pair
Trend + MomentumMACDADX > 20
Breakout MomentumRSI > 60Volume Spike + OBV↑
Acceleration CheckROCBollinger Band Width↑
Pullback EntryStoch RSI Cross↑Price > 21 EMA


4. Divergence in Price vs. Momentum
  • Used by: Discretionary institutional traders, macro traders
  • Statistical type: Leading indicator of exhaustion
  • Best used with:
    • RSI or ROC vs price
    • Volume divergence (OBV flat/down while price rises)
  • Caveat: Best in combination with range-bound or mean-reverting conditions
  • Recommended Setup for Divergence Detection
    Combine 1 or 2 momentum indicators with simple price structure tools:
    • RSI + MACD Histogram
    • ROC + Trendlines
    • AO + Price Swings
    • Stoch RSI + Support/Resistance
5. Order Flow Imbalances
  • Used by: High-frequency trading, execution algos
  • Concept: Institutional traders watch limit order book flow → imbalance leads price
  • Data Required: Level 2, DOM
  • Quant Proxy: Tick imbalance, delta (buy vs. sell pressure), CVD (cumulative volume delta)
  • Volume Profile indicator, Delta Volume/Bid-Ask Deltas, Cumulative Delta, VWAP & Standard Deviations and Market Structure with Volume Surge
6. Volatility Expansion / Compression
  • Used by: Options desks, gamma scalpers
  • Quant tool:
    • IV Rank/Percentile
    • HV vs. IV comparison
    • Bollinger Band width
  • Why it works: Options are priced on expected volatility. When reality diverges from pricing, opportunity arises.
Bonus: Repeated Institutional “Footprint” Patterns
These aren’t shapes like “cup and handle” — they are conditions that often signal institutional behavior:

Pattern ConditionImplication
Price flat, volume risingAccumulation or distribution
Sharp drop, no volumeLack of conviction / likely bounce
High OI + gamma at strikeOption dealer positioning
Multiple failed breakoutsLiquidity hunt / stop runs

So what should you look for?
If you want to think like an institution, prioritize conditions, not shapes.

Instead of:​

  • “I think this is a head and shoulders”, Think:
    • “Price is failing to make higher highs while RSI is fading and volume is declining — that’s a statistically testable reversal setup.”
I agree with your review but here is a different view of your word choice
Apophenia (/æpoʊˈfiːniə/) is the tendency to perceive meaningful connections between unrelated things.[2]

• Your brain evolved to find patterns for survival. Thousands of years ago, spotting the pattern of rustling leaves might mean the difference between detecting a predator or becoming dinner. This served us well in the wild

• But in trading, this same survival mechanism works against you.

• Think about it: your brain processes visual information incredibly fast, but it's also incredibly biased. It looks for familiar shapes and tries to fit new information into patterns you already Know

Here's a quick test: Look at any chart for 30 seconds. Your brain will immediately start connecting dots, drawing invisible trend lines, and spotting "obvious" patterns. Head and shoulders here, double bottom there, clear breakout forming………
 
• Your brain evolved to find patterns for survival. Thousands of years ago, spotting the pattern of rustling leaves might mean the difference between detecting a predator or becoming dinner. This served us well in the wild

• But in trading, this same survival mechanism works against you.

@tellyt is correct.
Patterns are training wheels. They help beginning retail traders see something before they understand the underpinnings of stock market behavior.

@antwerks provides an excellent summation of the best pattern recognition. But pattern trading is not the path to long‑term profitability. To be successful in life, we learn to look beyond correlation and see causality. To be successful in trading, the same evolution is required.

Trader Development
LevelWhat They SeeResult
NoviceStatic patterns and chart shapes (flags, wedges, breakouts, double bottoms)Random outcomes driven by apophenia; trades feel inconsistent because shapes don’t explain strength, intent, or catalyst pressure
EmergingBehavior: who is in control, clean versus chaotic movement, strength versus exhaustion, liquidity behaviorMore consistent setups; begins filtering out noise and recognizing when a move has real sponsorship
ExperiencedCausality: catalyst strength, structural drift, trapped participants, liquidity vacuums, institutional intentPredictive edge; trades align with the forces that cause moves, not the shadows they leave behind

Social media, the news, and the people at the water cooler take the lazy route and follow the brain’s natural predilection for seeing patterns. The talking heads of the stock market do the same. Pattern hunting is easy to teach, easy to package, and easy to sell.

Patterns are not what is causing price movement.
Behavior creates moves. Behavior presents in many patterns and sometimes without any.
Causality sustains moves.
 
Last edited by a moderator:
@tellyt is correct.
Patterns are training wheels. They help beginning retail traders see something before they understand the underpinnings of stock market behavior.

@antwerks provides an excellent summation of the best pattern recognition. But pattern trading is not the path to long‑term profitability. To be successful in life, we learn to look beyond correlation and see causality. To be successful in trading, the same evolution is required.

Trader Development
LevelWhat They SeeResult
NoviceStatic patterns and chart shapes (flags, wedges, breakouts, double bottoms)Random outcomes driven by apophenia; trades feel inconsistent because shapes don’t explain strength, intent, or catalyst pressure
EmergingBehavior: who is in control, clean versus chaotic movement, strength versus exhaustion, liquidity behaviorMore consistent setups; begins filtering out noise and recognizing when a move has real sponsorship
ExperiencedCausality: catalyst strength, structural drift, trapped participants, liquidity vacuums, institutional intentPredictive edge; trades align with the forces that cause moves, not the shadows they leave behind

Social media, the news, and the people at the water cooler take the lazy route and follow the brain’s natural predilection for seeing patterns. The talking heads of the stock market do the same. Pattern hunting is easy to teach, easy to package, and easy to sell.

Patterns are not what is causing price movement.
Behavior creates moves. Behavior presents in many patterns and sometimes without any.
Causality sustains moves.

Determining causality in stock patterns using other indicators is complex, markets are chaotic and influenced by many factors. However, you can approximate causal inference (not pure causality, but strong conditional relationships) by layering data intelligently. Here's how traders approach it:

1. Sequence-Based Confirmation (Before - After Logic)
Use indicators that lead price action vs. those that confirm it.
Example:
  • Volume spike → Breakout
    A surge in volume before price breakout implies accumulation (potential cause).
  • Divergence → Reversal
    RSI bearish divergence often precedes a top; this sequence strengthens causality.
2. Multi-Domain Analysis (Price × Momentum × Volatility)
Layer different indicator domains to explain why something moved.

DomainIndicator ExamplesCausal Insight Example
PriceTrendlines, Price PatternsStructure breaks show market intent
MomentumRSI, MACD, ROCWeakening momentum explains reversal setups
VolumeOBV, VWAP, Acc/Dist, DeltaVolume confirms institutional support/resistance
VolatilityATR, Bollinger Bands, VIXExpansion shows fuel for breakouts

3. Event-Based Conditioning
Causality can sometimes be inferred around known catalysts, such as:
  • Earnings → Price gap
    You can correlate earnings surprises with price and volume shifts.
  • FOMC decisions, CPI
    Map economic calendar events to spikes in volatility or reversals.
4. Statistical & Algorithmic Tools
Advanced users explore causal analysis with statistical tools:
  • Granger Causality (used in time-series analysis): Tests if one variable predicts another.
  • Bayesian networks / conditional probability trees
  • Machine learning: Lasso regression or causal forests to determine which indicators matter before a price move.
Practical Tactics (Used by Quant-Inspired Traders)
Correlate Events: Build a table of pattern occurrences with indicator states 5–10 bars before it.
  1. Backtest Pattern Triggering Conditions: Does the pattern only play out when certain indicators align?
  2. Build Indicator Stacks: Require "cause indicators" to align before the pattern confirms.
Example Use Case:
Bullish Flag Causality Layering:
  • Rising OBV → Suggests institutional buying before pattern
  • Tight Bollinger Bands → Low volatility, sets up explosion
  • Increasing MACD Histogram → Confirms upside momentum

This stack suggests a pattern that isn’t random—it has energy behind it.
CAUSALITY BULLISH SCANNER
Signal TypeLogic Detected
Volume PressureOBV rising (smart money flow)
MomentumPrice acceleration (ROC)
VolatilityCompression → potential energy
Price ConfirmBreakout beyond prior range

Here are 2 scanners that try to bridge that Gap;
Code:
# === Causality-Based Bullish Scanner ===
# Looks for volume pressure, momentum build, volatility squeeze BEFORE breakout

# === Inputs ===
input length = 14;
input squeezeLength = 20;

# === 1. Volume Pressure (Cause)
def OBV = TotalSum(if close > close[1] then volume else if close < close[1] then -volume else 0);
def obvRising = OBV > OBV[1] and OBV[1] > OBV[2];

# === 2. Momentum Leading (Cause)
def ROC = (close - close[length]) / close[length] * 100;
def rocUp = ROC > ROC[1];

# === 3. Volatility Squeeze (Fuel)
def stdDev = StDev(close, squeezeLength);
def bollWidth = BollingerBands().UpperBand - BollingerBands().LowerBand;
def lowVol = bollWidth < bollWidth[squeezeLength];

# === 4. Price Pattern Confirmation (Effect)
def breakout = close > Highest(close[squeezeLength], squeezeLength);

# === Final Causal Score
def causeScore = (obvRising and rocUp and lowVol);
def effect = breakout;

# === SCANNER TRIGGER
plot scan = causeScore and effect;

Explanation of Logic for the MACD_OBV_VOLATILITY_SQUEEZE_BO_SCANNER:
  • MACD rising: Shows increasing bullish momentum.
  • OBV rising: Confirms volume support behind the move.
  • Low Bollinger Width: Detects volatility compression or "squeeze."
  • Breakout from range: Shows price has resolved the compression upward.

Code:
declare lower;

input squeezeLength = 20;
input bbMult = 2.0;

# === MACD Signal
def macdLine = MACD().Value;
def macdSignal = MACD().Avg;
def macdRising = macdLine > macdSignal and macdLine > macdLine[1];

# === OBV Direction
def obv = TotalSum(Sign(close - close[1]) * volume);
def obvRising = obv > obv[1];

# === Bollinger Band Width (Squeeze)
def basis = Average(close, squeezeLength);
def dev = bbMult * StDev(close, squeezeLength);
def upper = basis + dev;
def lower = basis - dev;
def bollWidth = upper - lower;
def lowVol = bollWidth < Lowest(bollWidth, squeezeLength);

# === Breakout Condition
def breakout = close > Highest(close[squeezeLength], squeezeLength);

# === All Conditions Align
def bullishSetup = macdRising and obvRising and lowVol and breakout;

# === Scanner Output
plot scan = bullishSetup;
 
Last edited by a moderator:
cool. But....
Right now, your script is already very clean conceptually:
You have:
  • A bullish continuation probability (green)
  • A bearish continuation probability (red)
Those are conditional probabilities, not momentum. They answer: “When this trend state exists, how often does price continue on the next bar?”
That’s statistical edge, not force.
What you don’t explicitly show, “Is the current move accelerating or decelerating right now?”
That’s where a momentum plot would add value—not redundancy.
Think of your system as three layers:
  1. Trend definition
    → VWAP + HMA slope
  2. Statistical continuation probability
    → Your green/red probability lines
  3. Real-time force
    → Momentum (what price is doing now)
Right now, you have layers 1 and 2. A third plot would give you layer 3.
That turns this from a probability model into a decision engine.
Here’s how the interpretation would change with momentum added:
Without momentum:
You see:
  • Bull prob = 68%
  • Bear prob = 22%
That tells you “Statistically, bulls usually continue from here.”
But it doesn’t tell you, “Are they actually pushing right now?”
With momentum:
If momentum is rising while bull probability is high:
= High confidence continuation setup
If momentum is falling while bull probability is high:
= Warning: probability is favorable, but force is missing
That’s professional-level filtering right there, lol.

Your current model is structural probability.
Momentum would be dynamic confirmation.
They are not the same thing and they complement each other perfectly.

If you were to add a third plot, I would not use RSI or MACD.
You already have price structure and slope. Keep it native.
Something like:

momentum = close - close[3];
Or smoother:

def mom = ExpAverage(close - close[1], 3);
Then plot:
  • Positive → bullish force
  • Negative → bearish force
  • Crossing zero → momentum shift
Now you get:
ConditionInterpretation
High Bull Prob + Positive MomentumStrong continuation
High Bull Prob + Flat MomentumCaution
High Bull Prob + Negative MomentumFailure risk
Low Prob + Strong MomentumBreakout potential
High Bear Prob + Negative MomentumStrong downside continuation

What you’ve built already is statistically elegant.
Adding momentum would make it trading actionable.
Right now it tells you, “What usually happens.”
With momentum added, it tells you, “What is happening and how likely it is to continue.”
That combination is rare and very powerful.

Code:
## by Strehsum 1/24/2026
# ============================================
# Probability-Based Trend Continuation Model
# with Momentum Confirmation (5-Min)
# added Momentum angle antwerks 01/24/2026
# ============================================

declare lower;

# ---------- INPUTS ----------
input hmaLength    = 21;
input lookbackBars = 200;
input momLength    = 3;      # Momentum smoothing
input momLookback  = 3;      # Raw momentum lookback

# ---------- CORE REFERENCES ----------
def v = vwap();
def h = HullMovingAvg(close, hmaLength);
def hSlope = h - h[1];

# ---------- TREND STATES ----------
def bullTrend = close > v and hSlope > 0;
def bearTrend = close < v and hSlope < 0;

# ---------- CONTINUATION CONDITIONS ----------
def bullContinue = bullTrend[1] and close > close[1];
def bearContinue = bearTrend[1] and close < close[1];

# ---------- ROLLING COUNTS ----------
def bullTrendCount = Sum(bullTrend[1], lookbackBars);
def bullContCount  = Sum(bullContinue, lookbackBars);

def bearTrendCount = Sum(bearTrend[1], lookbackBars);
def bearContCount  = Sum(bearContinue, lookbackBars);

# ---------- PROBABILITIES ----------
def bullProb = if bullTrendCount > 0 then bullContCount / bullTrendCount else 0;
def bearProb = if bearTrendCount > 0 then bearContCount / bearTrendCount else 0;

# ---------- MOMENTUM ENGINE ----------
# Raw momentum: how far price moved over last N bars
def rawMomentum = close - close[momLookback];

# Smoothed momentum: reduces noise
def momentum = ExpAverage(rawMomentum, momLength);

# ---------- PROBABILITY PLOTS ----------
plot BullContinuationProb = bullProb;
BullContinuationProb.SetDefaultColor(Color.GREEN);
BullContinuationProb.SetLineWeight(2);

plot BearContinuationProb = bearProb;
BearContinuationProb.SetDefaultColor(Color.RED);
BearContinuationProb.SetLineWeight(2);

# ---------- MOMENTUM PLOT ----------
plot MomentumLine = momentum;
MomentumLine.SetLineWeight(2);
MomentumLine.AssignValueColor(
    if momentum > 0 then Color.CYAN
    else if momentum < 0 then Color.MAGENTA
    else Color.GRAY
);

# Zero line for momentum balance
plot MomZero = 0;
MomZero.SetDefaultColor(Color.DARK_GRAY);
MomZero.SetLineWeight(1);

# ---------- INTERPRETIVE LABELS ----------
AddLabel(yes,
    "Bull Trend Continuation: " + AsPercent(bullProb),
    Color.GREEN
);

AddLabel(yes,
    "Bear Trend Continuation: " + AsPercent(bearProb),
    Color.RED
);

AddLabel(yes,
    if momentum > 0 then "Momentum: Bullish"
    else if momentum < 0 then "Momentum: Bearish"
    else "Momentum: Neutral",
    if momentum > 0 then Color.CYAN
    else if momentum < 0 then Color.MAGENTA
    else Color.GRAY
);

# ---------- OPTIONAL: HIGH-CONFIDENCE ZONES ----------
# These don't plot, but you can use them for scans or signals later

def HighBullConfidence = bullProb > 0.6 and momentum > 0;
def HighBearConfidence = bearProb > 0.6 and momentum < 0;

These two in combination with option flow are looking very promising. Been testing on the hourly, so large AH jumps/dumps can be dangerous, but otherwise winners seem to have a high chance of big returns and losers are cut fairly quickly.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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