BAY Technical Indicators//@version=5
indicator("BAY Technical Indicators", overlay=true)
// Price source
price = close
// VWAP
vwap = ta.vwap
plot(vwap, title="VWAP", color=color.blue, linewidth=2)
// SMMA (RMA) 20 and 50
smma20 = ta.rma(price, 20)
smma50 = ta.rma(price, 50)
plot(smma20, title="SMMA 20", color=color.lime)
plot(smma50, title="SMMA 50", color=color.purple)
// EMA 9 and 21
ema9 = ta.ema(price, 9)
ema21 = ta.ema(price, 21)
plot(ema9, title="EMA 9", color=color.white)
plot(ema21, title="EMA 21", color=color.red)
// MA 200
ma200 = ta.sma(price, 200)
plot(ma200, title="MA 200", color=color.orange, linewidth=2)
// SMA 325 (Dark Green)
sma325 = ta.sma(price, 325)
plot(sma325, title="SMA 325", color=color.new(color.green, 0)) // Dark green
// Volume SMA 9 (plotted in data window only)
volume_sma9 = ta.sma(volume, 9)
plot(volume_sma9, title="Volume SMA 9", color=color.fuchsia, linewidth=1, display=display.data_window)
Chart-Muster
VCP Detector it detects VCP before breakout,,,
⚡ How to Use
🕒 Timeframe:
15-min → Intraday contraction
Daily → Swing contraction
🟢 Green circles = VCP zones
→ price tightening, volume drying, volatility compressing.
Market Structure Trailing Stop MTF [Inspired by LuxAlgo]# Market Structure Trailing Stop MTF
**OPEN-SOURCE SCRIPT**
*208k+ views on original · Modified for MTF Support*
This indicator is a direct adaptation of the renowned **Market Structure Trailing Stop** by **LuxAlgo** (original script: [Market Structure Trailing Stop ]()). The core logic remains untouched, providing dynamic trailing stops based on market structure breaks (CHoCH/BOS). The **only modification** is the addition of **Multi-Timeframe (MTF) support**, allowing users to apply the trailing stops and structures from **higher timeframes (HTF)** directly on their current chart. This enhances usability for traders analyzing cross-timeframe confluence without switching charts.
**Special thanks to LuxAlgo** for releasing this powerful open-source tool under CC BY-NC-SA 4.0. Your contributions to the TradingView community have inspired countless traders—grateful for the solid foundation!
## 🔶 How the Script Works: A Deep Dive
At its heart, this indicator detects **market structure shifts** (bullish or bearish breaks of swing highs/lows) and uses them to generate **adaptive trailing stops**. These stops trail the price while protecting profits and acting as dynamic support/resistance levels. The MTF enhancement pulls this logic from user-specified higher timeframes, overlaying HTF structures and stops on the lower timeframe chart for seamless multi-timeframe analysis.
### Core Logic (Unchanged from LuxAlgo's Original)
1. **Pivot Detection**:
- Uses `ta.pivothigh()` and `ta.pivotlow()` with a user-defined lookback (`length`) to identify swing highs (PH) and lows (PL).
- Coordinates (price `y` and bar index/time `x`) are stored in persistent variables (`var`) for tracking recent pivots.
2. **Market Structure Detection**:
- **Bullish Structure (BOS/CHoCH)**: Triggers when `close > recent PH` (break above swing high).
- If `resetOn = 'CHoCH'`, resets only on major shifts (Change of Character); otherwise, on all breaks.
- Sets trend state `os = 1` (bullish) and highlights the break with a horizontal line (dashed for CHoCH, dotted for BOS).
- Initializes trailing stop at the local minimum (lowest low since the pivot) using a backward loop: `btm = math.min(low , btm)`.
- **Bearish Structure**: Triggers when `close < recent PL`, mirroring the bullish logic (`os = -1`, local maximum for stop).
- Structure state `ms` tracks the break type (1 for bull, -1 for bear, 0 neutral), resetting based on user settings.
3. **Trailing Stop Calculation**:
- Tracks **trailing max/min**:
- On new bull structure: Reset `max = close`.
- On new bear: Reset `min = close`.
- Otherwise: `max = math.max(close, max)` / `min = math.min(close, min)`.
- **Stop Adjustment** (the "trailing" magic):
- On fresh structure: `ts = btm` (bull) or `top` (bear).
- In ongoing trend: Increment/decrement by a percentage of the max/min change:
- Bull: `ts += (max - max ) * (incr / 100)`
- Bear: `ts += (min - min ) * (incr / 100)`
- This creates a **ratcheting effect**: Stops move favorably with the trend but never against it, converging toward price at a controlled rate.
- **Visuals**:
- Plots `ts` line colored by trend (teal for bull, red for bear).
- Fills area between `close` and `ts` (orange on retracements).
- Draws structure lines from pivot to break point.
4. **Edge Cases**:
- Variables like `ph_cross`/`pl_cross` prevent multiple triggers on the same pivot.
- Neutral state (`ms = 0`) preserves prior `max/min` until a new structure.
### MTF Enhancement (Our Addition)
- **request.security() Integration**:
- Wraps the entire core function `f()` in a security call for each timeframe (`tf1`, `tf2`).
- Returns HTF values (e.g., `ts1`, `os1`, structure times/prices) to the chart's context.
- Uses `lookahead=barmerge.lookahead_off` for accurate historical repainting-free data.
- Structures are drawn using `xloc.bar_time` to align HTF lines precisely on the LTF chart.
- **Multi-Output Handling**:
- Separate plots/fills/lines for each TF (e.g., `plot_ts1`, `plot_ts2`).
- Colors and toggles per TF to distinguish HTF1 (e.g., teal/red) from HTF2 (e.g., blue/maroon).
- **Benefits**: Spot HTF bias on LTF entries, e.g., enter longs only if both TF1 (1H) and TF2 (4H) show bullish `os=1`.
This keeps the script lightweight—**no repainting, max 500 lines**, and fully compatible with LuxAlgo's original behavior when TFs are set to the chart's timeframe.
## 🔶 SETTINGS
### Core Parameters
- **Pivot Lookback** (`length = 14`): Bars left/right for pivot detection. Higher = smoother structures, fewer signals; lower = more noise.
- **Increment Factor %** (`incr = 100`): Speed of stop convergence (0-∞). 100% = full ratchet (mirrors max/min exactly); <100% = slower trail, reduces whipsaws.
- **Reset Stop On** (`'CHoCH'`): `'CHoCH'` = Reset only on major reversals (dashed lines); `'All'` = Reset on every BOS/CHoCH (tighter stops).
### MTF Support
- **Timeframe 1** (`tf1 = ""`): HTF for first set (e.g., "1H"). Empty = current chart.
- **Timeframe 2** (`tf2 = ""`): Second HTF (e.g., "4H"). Enables dual confluence.
### Display Toggles
- **Show Structures** (`true`): Draws horizontal lines for breaks (per TF colors).
- **Show Trailing Stop TF1/TF2** (`true`): Plots the stop line.
- **Show Fill TF1/TF2** (`true`): Area fill between close and stop.
### Candle Coloring (Optional)
- **Color Candles** (`false`): Enables custom `plotcandle` for body/wick/border.
- **Candle Color Based On TF** (`"None"`): `"TF1"`, `"TF2"`, or none. Colors bull trend green, bear red.
- **Candle Colors**: Separate inputs for bull/bear body, wick, border (e.g., solid green body, transparent wick).
### Alerts
- **Enable MS Break Alerts** (`false`): Notifies on structure breaks (bull/bear per TF) **only on bar close** (`barstate.isconfirmed` + `alert.freq_once_per_bar_close`).
- **Enable Stop Hit Alerts** (`false`): Triggers on stop breaches (long/short per TF), using `ta.crossunder/crossover`.
### Colors
- **TF1 Colors**: Bullish (teal), Bearish (red), Retracement (orange).
- **TF2 Colors**: Bullish (blue), Bearish (maroon), Retracement (orange).
- **Area Transparency** (`80`): Fill opacity (0-100).
## 🔶 USAGE
Trailing stops shine in **trend-following strategies**:
- **Entries**: Use structure breaks as signals (e.g., long on bullish BOS from HTF1).
- **Exits**: Trail stops for profit-locking; alert on hits for automation.
- **Confluence**: Overlay HTF1 (e.g., 1H) for bias, HTF2 (e.g., Daily) for major levels—enter LTF only on alignment.
- **Risk Management**: Lower `incr` avoids early stops in chop; reset on `'All'` for aggressive trailing.
! (i.imgur.com)
*HTF1 shows bullish structure (teal line), trailing stop ratchets up—long entry confirmed on LTF pullback.*
! (i.imgur.com)
*TF1 (blue) bearish, TF2 (red) neutral—avoid shorts until alignment.*
! (i.imgur.com)
*Colored based on TF1 trend: Green bodies on bull `os=1`.*
Pro Tip: Test on demo—pair with LuxAlgo's other tools like Smart Money Concepts for full structure ecosystem.
## 🔶 DETAILS: Mathematical Breakdown
On bullish break:
- Local min: `btm = ta.lowest(n - ph_x)` (optimized loop equivalent).
- Stop init: `ts = btm`.
- Update: `Δmax = max - max `, `ts_new = ts + Δmax * (incr/100)`.
Bearish mirrors with `Δmin` (negative, so decrements `ts`).
In MTF: HTF `time` aligns lines via `line.new(htf_time, level, current_time, level, xloc.bar_time)`.
No logs/math libs needed—pure Pine v5 efficiency.
## Disclaimer
This is for educational purposes. Not financial advice. Backtest thoroughly. Original by LuxAlgo—modify at your risk. See TradingView's (www.tradingview.com). Licensed under CC BY-NC-SA 4.0 (attribution to LuxAlgo required).
DanteVita Broadening FormationsThis indicator marks off broadening formations. While many people think these are uncommon they are actually the core mechanic of price discovery that all trading is based on. Price discovery happens within a broadening formation until it breaks to another range, then more price discovery in the new range. These are used heavily by "The Strat" by Rob Smith. Learn it.
If it is running too slow for you, reduce number of bars or number of formations it will search for.
Day of Week LetterLetters printed on the Daily candle corresponding the day of the trading week it is on. Used for weekly range logic
Set it to 'bring to front' to see it
Inside Day FinderWhat is an Inside Day?
An inside day happens when:
Today’s high is lower than yesterday’s high, and
Today’s low is higher than yesterday’s low.
So, today’s candle is inside the previous day’s range — showing consolidation or indecision in the market.
Pair Trade Beta Calculator (WORKING VERSION)wrote by chatgpt5, calucate the beta for pair trading
Asset A: The asset you would like to long
Assest B: The asset you would like to short
celenni//@version=6
strategy("Cruce SMA 5/20 – v6 (const TF, gap en puntos SOLO cortos, next bar open, 1 trade/ventana, anti-flip)",
overlay = true,
initial_capital = 10000,
default_qty_type = strategy.percent_of_equity,
default_qty_value = 10,
pyramiding = 0)
// === CONSTANTES ===
const string TF = "15" // fija el timeframe de cálculo (ej. "5","15","30","60","120","240","D")
const string SYM_ALLOWED = "QQQ" // símbolo permitido
// === Inputs ===
confirmOnClose = input.bool(true, "Confirmar señal al cierre (evita repaint)")
maxGapPtsShort = input.float(0.50, "Máx gap permitido en CORTOS (puntos)", 0.0, 1e6)
lenFast = input.int(5, "SMA rápida", 1)
lenSlow = input.int(20, "SMA lenta", 2)
tpPts = input.float(20.0, "Take Profit (puntos)", 0.01)
slPts = input.float(5.0, "Stop Loss (puntos)", 0.01)
// Ventanas (NY)
useSessions = input.bool(true, "Usar ventanas NY")
sess1 = input.session("1000-1130", "Ventana 1 (NY)")
sess2 = input.session("1330-1600", "Ventana 2 (NY)")
flatOutside = input.bool(true, "Cerrar posición al salir de la ventana")
// === Utilidades ===
isAllowedSymbol() =>
(syminfo.ticker == SYM_ALLOWED) or str.contains(str.upper(syminfo.ticker), str.upper(SYM_ALLOWED))
// === Series MTF (cálculo en TF) ===
closeTF = request.security(syminfo.tickerid, TF, close, barmerge.gaps_off, barmerge.lookahead_off)
smaFast = ta.sma(closeTF, lenFast)
smaSlow = ta.sma(closeTF, lenSlow)
// Señales MTF sin repaint
longSignalTF = request.security(syminfo.tickerid, TF,
ta.crossover(ta.sma(close, lenFast), ta.sma(close, lenSlow)),
barmerge.gaps_off, barmerge.lookahead_off)
shortSignalTF = request.security(syminfo.tickerid, TF,
ta.crossunder(ta.sma(close, lenFast), ta.sma(close, lenSlow)),
barmerge.gaps_off, barmerge.lookahead_off)
// === Sesiones (evaluadas en el TF del gráfico, zona NY) ===
inSess1 = useSessions ? not na(time(timeframe.period, sess1, "America/New_York")) : true
inSess2 = useSessions ? not na(time(timeframe.period, sess2, "America/New_York")) : true
inSession = inSess1 or inSess2
// Inicio de ventanas y contadores (1 trade por ventana)
var bool wasIn1 = false, wasIn2 = false
win1Start = inSess1 and not wasIn1
win2Start = inSess2 and not wasIn2
wasIn1 := inSess1
wasIn2 := inSess2
var int tradesWin1 = 0, tradesWin2 = 0
if win1Start
tradesWin1 := 0
if win2Start
tradesWin2 := 0
justOpened = strategy.position_size != 0 and strategy.position_size == 0
if justOpened
if inSess1
tradesWin1 += 1
if inSess2
tradesWin2 += 1
canTakeMore =
(inSess1 and tradesWin1 < 1) or
(inSess2 and tradesWin2 < 1) or
(not useSessions)
// === Filtro NO-GAP SOLO para CORTOS (en PUNTOS) ===
// Compara OPEN actual vs CLOSE previo; se evalúa en la barra donde se EJECUTA (apertura actual).
gapPts = math.abs(open - close )
shortGapOK = maxGapPtsShort <= 0 ? true : (gapPts <= maxGapPtsShort)
// === Anti-flip y gating ===
isFlat = strategy.position_size == 0
canSignal = (not confirmOnClose or barstate.isconfirmed)
canTrade = isAllowedSymbol() and inSession and canTakeMore and canSignal
// === ENTRADAS (se colocan al cierre; se llenan en la apertura siguiente) ===
// Largos: sin filtro de gap
if canTrade and isFlat and longSignalTF
strategy.entry("Long", strategy.long)
// Cortos: requieren shortGapOK
if canTrade and isFlat and shortSignalTF and shortGapOK
strategy.entry("Short", strategy.short)
// === TP/SL en puntos ===
if strategy.position_size > 0
e = strategy.position_avg_price
strategy.exit("TP/SL Long", from_entry="Long", limit=e + tpPts, stop=e - slPts)
if strategy.position_size < 0
e = strategy.position_avg_price
strategy.exit("TP/SL Short", from_entry="Short", limit=e - tpPts, stop=e + slPts)
// === Cierre fuera de sesión ===
if flatOutside and not inSession and strategy.position_size != 0
strategy.close_all("Fuera de sesión")
// === Visual ===
plot(smaFast, color=color.new(color.teal, 0), title="SMA 5 ("+TF+")")
plot(smaSlow, color=color.new(color.orange, 0), title="SMA 20 ("+TF+")")
plotshape(longSignalTF and canTrade and isFlat, title="Compra", style=shape.triangleup,
location=location.belowbar, color=color.new(color.teal,0), size=size.tiny, text="Long")
plotshape(shortSignalTF and canTrade and isFlat and shortGapOK, title="Venta", style=shape.triangledown,
location=location.abovebar, color=color.new(color.red,0), size=size.tiny, text="Short")
Engulfing StrategyThis indicator has the following key features:
- Detects bullish and bearish engulfing candlestick patterns using a well-established price and body comparison logic.
- Incorporates a customizable moving average filter with multiple smoothing options to confirm trend direction.
- Highlights both the current and previous candles involved in the engulfing pattern by coloring them distinctly, improving visual clarity for reversal signals.
- Offers an interchangeable mode allowing the user to switch between a fully automated trading strategy (entries and exits) and a simple indicator mode (signal and color visualization only).
- Supports pyramiding positions and accounts for commissions and initial capital for realistic strategy testing.
- Uses modern Pine Script v5 functions and syntax for reliable and efficient execution.
- Provides clear visual bar colors for bullish (orange) and bearish (yellow) engulfing signals.
- Allows configuration of MA type and period, adapting to various trading styles and assets.
These features make it a versatile tool for traders seeking both visual confirmation and automated trade execution based on engulfing candle patterns combined with trend filtering.
by @Tumiza999
Candle Body RatioThis indicator is designed to calculate the percentage of the upper wick, the body, and the lower wick of the candle over which your cursor is positioned.
✅ Market Maker Levels (v6 Labels + Prices, No Zones)this shows previous day and weeks high n low which helps in managing the trades to find support and resistance
Candle PA Scanner (Engulfing / Inside / Pin) by BK SahniHere’s how to read the “Candle PA Scanner (Engulfing / Inside / Pin)” and what each input means.
What the signals look like on your chart
B-ENG (label above/below bar)
Bullish Engulfing → “B-ENG” below the bar (green/teal).
Bearish Engulfing → “B-ENG” above the bar (red).
IB (small orange dot at the top)
Inside Bar (compression). Use the mother bar’s high/low for the break.
PIN (triangle)
Bullish Pin → triangle below the bar (long lower wick; rejection of support).
Bearish Pin → triangle above the bar (long upper wick; rejection of resistance).
Treat these as price-action alerts, not automatic buy/sell signals. Act only when they occur at your levels (VWAP band, Fib 38.2–61.8, PDH/PDL, OB/FVG, etc.).
How to trade the prints (quick rules)
A) Bullish Engulfing at support
Context: at VWAP/VAL/0.5–0.618 Fib.
Entry: next candle above the engulfing high (or market order on close if volume/momentum confirm).
Stop: a tick below the engulfing low (or below the level).
Targets: mid/range, VWAP, prior swing; trail with Chandelier/ATR if trend extends.
B) Bearish Engulfing at resistance
Mirror the above: trigger below the engulfing low; stop above its high.
C) Inside Bar
It’s compression. Mark the mother bar’s high/low.
Trade the breakout in the direction of bias (above VWAP for longs, below for shorts).
If the break fails (closes back inside), often sets up a reversal—manage fast.
D) Pin Bar (rejection)
Enter on break of the pin’s body in the direction away from the wick.
Stop beyond the wick tip (invalidated if wick gets closed through).
Scale at VWAP/mid or the opposite range edge.
What the Inputs do (the panel you showed)
Inside Bar lookback (default 1)
How many bars back can be the mother bar.
Keep 1 for strict IB; raise to 2–3 to catch nested/compression patterns (more signals, a bit noisier).
Pin wick:body min ratio (default 2)
How long the rejection wick must be compared to the body.
Higher (2.5–3.0) = pickier, great in chop.
Lower (1.5–1.8) = more pins, useful in strong trends where wicks are shorter.
Min body % of range (0–1) (default 0.25)
Filters out dojis. The body must be at least 25% of the bar’s high-low range.
If you want to allow slimmer bodies (more pins/dojis), drop to 0.15–0.20.
If you want only decisive bodies, raise to 0.30–0.35.
Suggested tuning by market state
Trending / high momentum:
IB lookback 1, Pin ratio 1.8–2.2, Min body 0.20–0.25 (to catch more continuation entries).
Ranging / choppy:
IB lookback 2, Pin ratio 2.5–3.0, Min body 0.30 (fewer, higher-quality reversals).
A simple confluence checklist (use before clicking)
Signal printed at a level (VWAP band, Fib, PDH/PDL, OB/FVG)?
Bias aligned (above VWAP for longs, below for shorts) or you’re intentionally fading a range edge?
For engulfing: did it close through nearby minor structure?
For IB: are you trading the mother bar break, not just the small inside candle?
Risk defined: stop beyond wick/zone, target mapped (mid/VWAP/swing/extension).
Common pitfalls
Taking signals mid-range (low R:R).
Treating an IB as a reversal without a break/shift.
Buying a bullish pin that closed below your level (no acceptance).
Ignoring volatility—during news spikes, patterns fail more often.
KANNADI MOHANRAJA SCALPING INDICATORThis indicator is designed by Kannadi Mohanraja to help traders visually identify uptrend conditions using 3-minute Heikin Ashi candles only.
🔍 Concept:
Heikin Ashi candles smooth price movements and help traders identify the market direction clearly.
When a Heikin Ashi candle closes above its open (green candle), it indicates potential bullish momentum.
⚙️ How it Works:
The script requests Heikin Ashi data from the 3-minute timeframe.
When the Heikin Ashi close price is greater than the open, it highlights the background in green to signal a potential uptrend.
A small “BUY” triangle appears below bars during these uptrend phases.
🧠 Purpose:
This script helps traders quickly recognize uptrend phases visually without using multiple indicators.
It’s ideal for scalpers and short-term traders who use Heikin Ashi charts for smooth price action confirmation.
⚠️ Note:
This indicator uses only Heikin Ashi candles — no other indicators are included.
Works best on charts set to 3-minute timeframe.
Use this as a visual guide, not as standalone trading advice.
#HeikinAshi #Uptrend #KannadiMohanraja #PineScriptV6 #Scalping
//@version=6
// © Kannadi Mohanraja
// This script is open-source and free to use for educational and analytical purposes.
// You may copy, modify, or share it with proper credit to the original author.
// Not intended as financial advice. Use at your own risk.
HITESH SOMANI Strategy Technical based strategy. Strong chart pattern based strategy for working professionals who dont have much time for trading
EMAs 4/8/15 + Classic Pivots (clean v5)Here is a clean code for people to use, hope it works well for you. 4/8/15 are key indicators. You first got to be on the right side or upside of the 15 and then you need to see a detachment from the 4/8. You will see that is when upward movement happens. for shorting, you need to be below the 4/8 and usually on the under of 15.
RaviossaThis indicator identifies false breakouts and confirmed breakouts on any timeframe. It automatically analyzes price action around key levels (such as recent highs and lows) to detect when the price temporarily breaks above or below a level but then quickly returns — signaling a false breakout.
When a breakout is confirmed (price holds beyond the level with strong volume or momentum), the indicator highlights it with a different color.
TMA SWING USE HOURLY TFTma Swing use hourly is a very strong potential buy and sell signal strategy where it give buy signal when 50 ema croses 200 ema and vise versa
BlackScrum Swing Boxes 1/2/3 After seeing influencers selling their indicator suite's online, I decided to start making replicas of them, maybe mine are better, maybe they are worse. I use them in my day to day trading and they help me make money, hopefully they help you make money.
Not financial advice, Do Your Own Research.
Everything provided without warranty or liability. If you stuff up, learn from it, get better, we all make mistakes.
// BlackScrum — 1/2/3-Bar Swing Boxes (auto timeframe)
//
// DESCRIPTION
// This indicator displays three swing-direction boxes (1B, 2B, 3B) in the top-right corner of the chart.
// The boxes automatically adapt to the chart's timeframe (15m, 1H, 4H, 1D, etc.).
// Each box represents the direction of the most recently confirmed swing pivot:
// • 1B → 1-bar swing (fastest, most sensitive)
// • 2B → 2-bar swing (medium confirmation)
// • 3B → 3-bar swing (slowest, strongest confirmation)
//
// COLORS
// • GREEN = last confirmed swing pivot was a higher low (up swing)
// • RED = last confirmed swing pivot was a lower high (down swing)
// • GREY = no clear swing yet (fresh/transition area)
//
// CONFLUENCE
// • ALL GREEN = bullish alignment across 1B, 2B, 3B → strong trend continuation signal
// • ALL RED = bearish alignment across all three → strong downtrend continuation signal
//
// HOW TO USE (TRADEPLAY)
//
// 1) ENTRIES
// • Aggressive entry → enter when ALL GREEN prints on your timeframe.
// • Safer pullback entry → wait for 1B to briefly turn red during a green 2B/3B,
// then flip back to green. Enter on the re-flip.
// • Multi-timeframe filter:
// Take longs only when higher TF (e.g., 1H/4H) boxes are at least neutral-to-green.
//
// 2) EXITS
// • Weakness exit → when 1B flips against your position while 2B is neutral/red.
// • Full exit → when ALL RED prints.
// • Time stop → if price hasn’t moved after several bars of your execution timeframe.
//
// 3) STOP-LOSS / RISK
// • Place stops beyond the latest opposite swing used by 2B or 3B.
// • Add 0.5–1× ATR buffer if your market has stop-hunt volatility.
// • Always size position based on the distance to the swing stop.
//
// 4) WHEN TO IGNORE SIGNALS
// • Chop zones → 1B flipping repeatedly while 2B/3B disagree.
// • News candles → wait for pivots to confirm on the *closed* bar.
//
// 5) USING WITH OTHER TOOLS
// • With a trend ribbon (e.g., Larsson-style):
// Only take ALL GREEN longs when the ribbon is UP, and ALL RED shorts when ribbon is DOWN.
// • With a Fear & Greed index:
// Prefer longs when F&G > 60,
// Avoid longs when F&G < 40 unless countertrend scalping.
//
// 6) TIMEFRAME GUIDANCE
// • Scalping: 5m / 15m, confirmed by 1H or 4H boxes.
// • Swinging: 1H / 4H with daily filter.
// • Positioning: 1D with weekly confirmation.
//
// 7) INTERPRETATION CHEATSHEET
// • 1B green, 2B grey, 3B red → short-term bounce inside higher timeframe downtrend.
// • 1B/2B green, 3B grey → early trend reversal forming.
// • All grey → fresh swing area; wait for direction.
//
// 8) CUSTOMIZATION
// • len1 / len2 / len3 control sensitivity (higher = slower & cleaner).
// • Can add a timeframe header box (e.g., “15m / 4H / 1D”).
// • Can add a multi-timeframe grid (e.g., 15m | 1H | 4H | 1D each with 1B/2B/3B).
//
// ====================================================================================================
Oversold Screener · v4# Step-2 Oversold Screener · v3.3
US equities · 15-minute event engine · AVWAP entries A–F · optional CVD/RSI/Z guards
## What this script does
Finds short, emotion-driven selloffs in large, healthy US stocks and turns them into actionable, right-side opportunities.
On a qualified 15-minute close it:
1. emits a minimal webhook so your backend/AI can vet the news and fundamentals, and
2. anchors an Event-AVWAP and plots ±1/±2/±3σ bands to guide entries A–F as price mean-reverts.
The logic runs in a fixed 15-minute space, independent of the chart timeframe you view.
## How an event is detected (Step-2 signal)
All conditions are evaluated on 15-minute data, including extended hours.
Depth, measured vs yesterday’s RTH reference
* Reference = min(yesterday’s RTH VWAP proxy, yesterday’s Close).
* 4h depth: current price vs reference across 16×15m bars ≤ threshold (default −4%).
* 8h depth: lowest close across the last 32×15m bars vs reference ≤ threshold (default −6%).
Relative underperformance
* Versus market ETF (SPY/QQQ) and sector ETF (XLK/XLF/XLY… or KWEB/CQQQ).
* Uses the same 16/32×15m windows; stock must be weaker by at least the set margins (default −3%).
Macro circuit breakers (any one trips = suppress signal)
* VIX level ≥ fuse (default 28).
* Market 4h/8h drawdown ≤ limits (default −2.0% / −3.5%).
* Sector 4h/8h drawdown ≤ limits (default −2.5% / −4.0%).
Momentum and distribution guards
* RSI(1h) < 30 by default (computed from 15m series).
* Optional Z-score filters: stock Z ≤ zTrig, and macro Z floors for market/sector.
* Cooldown per symbol so you don’t get spammed by repeated events.
When the event closes, the script posts a tiny JSON to your alert webhook and pins an on-chart “S2” marker at the event bar.
## Event-AVWAP and bands
From the event bar forward the script computes AVWAP natively in 15m space and draws bands at ±1σ/±2σ/±3σ.
σ is a rolling standard deviation of typical price with optional EMA smoothing and an optional cap.
Why this helps
* AVWAP from the shock timestamp approximates the crowd’s average position after the selloff.
* Reclaiming key bands often marks the start of orderly mean reversion rather than a dead-cat bounce.
## Entry proposals A–F (right-side confirmations)
Each entry requires first touching a lower band, then reclaiming a higher band.
A touch ≤ −2σ, then cross up through −1σ
B touch ≤ −1σ, then reclaim AVWAP
C break above −1σ, retest near −1σ within N bars, then bounce
D after compression (low ATR%), reclaim AVWAP
E touch ≤ −3σ, then cross up through −2σ
F touch ≤ −3σ, then cross up through −1σ (fast, aggressive)
Labeling hygiene
* Only the first three occurrences of each type A–F are shown within a one-week window after the event.
* A debounce interval avoids over-labeling across adjacent bars.
## Optional CVD gate (order-flow confirmation)
When enabled, entries must also pass a 15-minute CVD gate that looks for sell pressure exhaustion and a turn-up in cumulative delta.
Defaults are conservative; start with CVD off until you’re comfortable, then enable to filter chop after capitulations.
## Alert payload (minimal by design)
On the event bar close the script fires one alert with a tiny JSON that is easy to route and process in bulk:
```json
{
"event": "Crash_signal_15m",
"symbol": "NVDA",
"symbol_id": "NASDAQ:NVDA",
"ts_alert_15m_ms": 1730898900000,
"ts_alert_15m_local": "2025-11-06 10:45"
}
```
Notes
* ts_alert_15m_ms is the 15-minute close time in milliseconds since epoch (UTC reference).
* ts_alert_15m_local uses your chart’s timezone for readability.
Optional: a 24-hour streaming mode can resend this minimal payload on every 15-minute close during the day after the event (tiny patch available on request).
## Inputs you will actually touch
Bench/Sector symbols
* Bench: SPY or QQQ. Sector: XLK/XLF/XLY… or KWEB/CQQQ depending on the name.
Depth and relative thresholds
* 4h depth ≤ −4%, 8h depth ≤ −6%.
* Relative to market/sector ≤ −3% each.
Macro fuses
* VIX ≥ 28; market ≤ −2.0%/−3.5%; sector ≤ −2.5%/−4.0%.
Z/RSI guards
* Z window 80 bars (15m), stock zTrig ≤ −1.5, macro floors ≥ −1.0.
* RSI(1h) < 30.
AVWAP band engine
* σ EMA length 3; σ cap off by default.
* Retest window for entry C: 24 bars (≈6 hours).
Presentation and hygiene
* One-week entry window; per-type cap 3; debounce 8×15m bars.
* Signal table on/off, label pinning on/off.
## How to run it
1. Open a 15-minute chart (extended hours enabled recommended).
2. Add the indicator and choose Bench/Sector for the names you are reviewing.
3. Create a single alert per chart with Condition = Any alert() function call and Options = Once per bar close.
4. Point the alert to your webhook URL (or use app/email if you don’t have a URL).
5. Let your backend/AI receive the minimal JSON, do the news/fundamentals check, and decide Allow / Hold / Reject.
6. For Allowed names, use the on-chart A–F markers to stage in; manage risk against Event-AVWAP and upper HVNs/POC.
## Defaults that work well
* RSI(1h) < 30
* Depth 4h/8h ≤ −4%/−6% vs yesterday’s reference
* Relative to market/sector ≤ −3%
* Z: stock ≤ −1.5; macro floors ≥ −1.0
* Fuses: VIX ≥ 28; market ≤ −2.0%/−3.5%; sector ≤ −2.5%/−4.0%
* Bands: σ EMA = 3; no σ cap; one-week window; 3 labels per type
## Notes and limitations
* This is an indicator, not an auto-trader. Position sizing and exits are up to you.
* Designed for liquid US equities; thin ADRs and micro-caps are noisy.
* All event logic and entries are evaluated on bar close; AVWAP and bands do not repaint.
* If you need to monitor many symbols without a server, a Scanner variant can batch 10–17 tickers per script and alert without a webhook.
WM & HS Radar (Block-Free)The W/M + H&S Radar automatically scans for double-top/double-bottom (M and W) and head-and-shoulders style reversal structures across any timeframe.
How it works:
Detects repeating pivot formations that resemble W (double bottom) or M (double top) structures.
Draws neckline levels for each pattern and highlights potential breakout points.
Confirms breakout validity when price closes beyond the neckline (optionally requiring a 1.2× volume surge).
Generates alerts when a valid W Long or M Short trigger occurs.
Best used on: 15m, 1h, or 4h charts to identify medium-term reversal entries.
Recommended companion: Orion Daily HL + Volume indicator for higher-timeframe context.
Alert Options:
“W Long Trigger” → Bullish reversal breakout.
“M Short Trigger” → Bearish reversal breakout.
Usage Tip:
Combine with your support/resistance zones and ATR-based stop sizing from your Money Momentum Tracker to validate A-setups only.
First 5-Min Candle High/Low by grantratcliff7Draws two pale yellow lines at the open and the close of the first 5 min candle of the trading session (9:35 EDT)






















