Volume Trade Detector For ThinkOrSwim

cando13579

Member
VIP
📘 Volume Trade Detector
Volume Trade Detector identifies high-probability breakout and breakdown candles by combining volume spikes with price-action confirmation. The study highlights moments when strong momentum enters the market, often signaling institutional participation or algorithmic activity.
WA7i5Ua.png


Core Logic
  • Detects tee levels of volume spikes using customizable tesholds
  • Confirms signals only when candles show:
    • Bullish close + large range → BUY
    • Bearish close + large range → SELL
  • Range expansion is defined as > 1.5× the 20-period average candle size
Signals & Display
  • Green vertical line for BUY signals
  • Red vertical line for SELL signals
  • Optional chart bubbles showing timestamp and volume
  • Dashboard labels display cuent volume, average volume, signal strength, and live status
  • Optional real-time alerts when signals trigger
Use Cases
  • 5m–15m: intraday breakout detection, trend continuation
  • 30m–1H: swing confirmation, major momentum shifts
Why It Works
Volume Trade Detector filters noise by requiring both unusual volume and strong price expansion. This combination isolates meaningful momentum events that often mark the start of powerful directional moves.

1️⃣ Volume Spike Classification
The script uses tee customizable volume thresholds:
  • Level 1 Spike — Moderate activity
  • Level 2 Spike — Strong activity
  • Level 3 Spike — Very strong / institutional-level activity
When real-time volume exceeds these thresholds, the candle is tagged as a volume event.
Higher volume equals stronger “signal strength,” displayed as 1, 2, or 3.

2️⃣ Price Action Confirmation
A volume spike alone is not enough.
To reduce noise, the candle must also show:
✔ Candle Direction
  • Green (close > open) → potential BUY setup
  • Red (close < open) → potential SELL setup
✔ Range Expansion
The candle must be significantly larger than normal:
This confirms momentum, not just random volume.

3️⃣ Signal Generation
A valid signal occurs only when:
BUY Signal
  • Volume spike (any level)
  • Large range candle
  • Candle closes bullish
SELL Signal
  • Volume spike
  • Large range candle
  • Candle closes bearish
This combination filters out noise and identifies true breakouts, breakdowns, and trend acceleration candles.


📊 What the Indicator Displays
Vertical Lines
  • Green line = Buy signal
  • Red line = Sell signal
Plotted directly at the candle where conditions are met.

Chart Bubbles
Each signal prints a bubble showing:
  • Timestamp (optional)
  • Volume of the candle (optional)
Buy bubbles are green; sell bubbles are red.
"Commented out"

Dashboard Labels
Always visible on the chart:
  • Current Volume
  • 20-Period Average Volume
  • Signal Strength (1–3)
  • Current
  • Status: BUY / SELL / NONE
This provides instant context to assess momentum at a glance.

Alerts
The script includes optional alerts:
  • Popup + sound when a buy signal prints
  • Popup + sound when a sell signal prints
Code:
# Volume Trade Detector By CANDO13579
declare upper;

# Input parameters
input volumeThreshold1 = 1000;
input volumeThreshold2 = 2000;
input volumeThreshold3 = 3000;
input timeWindow = 5;
input showTime = yes;
input showVolume = yes;
input useBuyAlerts = yes;
input useSellAlerts = yes;
input showBuySignals = yes;
input showSellSignals = yes;
input showVerticalLines = yes;

# Calculate average volume for comparison
def avgVolume = Average(volume, 20);

# Detect volume spikes
def isVolumeSpike1 = volume >= volumeThreshold1 and volume < volumeThreshold2;
def isVolumeSpike2 = volume >= volumeThreshold2 and volume < volumeThreshold3;
def isVolumeSpike3 = volume >= volumeThreshold3;

# Determine signal strength (higher volume = stronger signal)
def signalStrength = if isVolumeSpike3 then 3 else if isVolumeSpike2 then 2 else if isVolumeSpike1 then 1 else 0;

# Price action conditions for buy/sell signals
def isUpBar = close > open;
def isDownBar = close < open;
def avgRange = Average(high - low, 20);
def isLargeRange = (high - low) > avgRange * 1.5;

# Generate buy/sell signals on volume spikes with price confirmation
def buySignal = (isVolumeSpike1 or isVolumeSpike2 or isVolumeSpike3) and isUpBar and isLargeRange;
def sellSignal = (isVolumeSpike1 or isVolumeSpike2 or isVolumeSpike3) and isDownBar and isLargeRange;

# Plot buy signals as arrows
#plot BuyArrow = if showBuySignals then buySignal else Double.NaN;
#BuyArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
#BuyArrow.SetDefaultColor(Color.GREEN);
#BuyArrow.SetLineWeight(2);

# Plot sell signals as arrows
#plot SellArrow = if showSellSignals then sellSignal else Double.NaN;
#SellArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#SellArrow.SetDefaultColor(Color.RED);
#SellArrow.SetLineWeight(2);

# Add vertical lines for signals
AddVerticalLine(showVerticalLines and buySignal, "Buy", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(showVerticalLines and sellSignal, "Sell", Color.RED, Curve.SHORT_DASH);

# Alerts
Alert(useBuyAlerts and buySignal, "Trade Detector Buy Signal - Volume: " + AsText(volume), Alert.BAR, Sound.Chimes);
Alert(useSellAlerts and sellSignal, "Trade Detector Sell Signal - Volume: " + AsText(volume), Alert.BAR, Sound.Bell);

# Add bubbles for labels
AddChartBubble(buySignal or sellSignal,
               if buySignal then low else high,
               (if showTime then GetYYYYMMDD() + " " + AsText(GetTime()) + "\n" else "") +
               (if showVolume then "Vol: " + AsText(volume) else ""),
               if buySignal then Color.GREEN else Color.RED,
               if buySignal then no else yes);

# Current status labels
AddLabel(yes, "Current Volume: " + AsText(volume), Color.WHITE);
AddLabel(yes, "Avg Volume: " + AsText(Round(avgVolume, 0)), Color.WHITE);
AddLabel(yes, "Signal Strength: " + AsText(signalStrength),
         if signalStrength == 3 then Color.RED else if signalStrength == 2 then Color.ORANGE else if signalStrength == 1 then Color.YELLOW else Color.GRAY);
AddLabel(yes, "Status: " + (if buySignal then "BUY" else if sellSignal then "SELL" else "NONE"),
         if buySignal then Color.GREEN else if sellSignal then Color.RED else Color.GRAY);
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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