⚠️   Important Disclaimer — Please Read Before Continuing   ⚠️
Disclaimer - Ashish Trader - Risk Warning

📌 This website is for educational and informational purposes only. Ashish Mishra is NOT a SEBI-Registered Advisor. Trading involves substantial risk of loss. Please consult a SEBI-registered financial advisor before making any trading or investment decisions.  |  Read Full Disclaimer →

Sniper Indicator V.12.0 Pro Max

Sniper Indicator V.12.0 Pro Max Banner
👑 Institutional Release V.12.0 Pro Max

Sniper Indicator V.12.0 Pro Max — Pin Bar Rejection @ S/R, PDH/PDL Engine & Sleek Dashboard Edition

ðŸ”Ļ Pin Bar @ Key Zones + 📌 PDH/PDL Price Labels + ⚡ Compact Top-Right Dashboard + 📈 Signal History Trail + Zero Lag Optimization

Namaskar Dosto! Ashish Trader Official Website par aapka swagat hai. Aaj hum launch kar rahe hain hamara ab tak ka sabse advanced aur powerful trading system — Sniper Indicator V.12.0 Pro Max Edition!

Is naye update mein humne intraday scalpers aur option buyers ki sabse badi problems ko solve kiya hai: Chart Clutter ko hatakar bilkul saaf kiya, har level par uska naam aur exact price tag lagaya, aur Support/Resistance par bante hi Reversal Pin Bars ko auto-detect karne ka engine joda hai.

⚡ Master Upgrade: Clutter-Free Trading & Instant 1-Second Glances

Dashboard ko ultra-sleek aur Tiny banakar Top-Right me fix kar diya gaya hai. Faltu duplicate rows hata di gayi hain, aur bottom dashboard default OFF hai taaki aapka pura chart 100% clean aur price action focused rahe!

🚀 V.12.0 Pro Max Key Features & Upgrades

ðŸ”Ļ Pin Bar Rejection @ S/R

Support (PDL, CPR, 9:30 SUP) par bante hi Hammer (Call Buy) aur Resistance (PDH, CPR, 9:30 RES) par Shooting Star (Put Buy) labels aur alerts deta hai.

📌 PDH & PDL Engine

Previous Day High (Orange Dashed) aur Previous Day Low (Cyan Dashed) lines with exact price tags. Dedicated ON/OFF and color controls.

🏷️ Full S/R Name & Price Labels

Chart ki har horizontal line par uska naam aur rate likha hai: RES 24,350, SUP 24,100, 9:30 RES, 9:30 SUP, EOR, EOS.

📈 Signal History Trail Line

Purane BUY (Green) aur SELL (Red) dots ko ek trail line se connect karta hai taaki aap previous trend structure ko 1 second me review kar sakein.

ðŸŽŊ CPR Market Classifier

Narrow CPR 🚀: Trending day expected.
Wide CPR ⚠️: Sideways / Rangebound day alert.

📊 Real-time OI & Synthetic PCR

Live Option Interest Buildup (Long/Short Buildup, Unwinding) aur Option Writers positioning live terminal par show hoti hai.

📋 Level Identification Cheat Sheet

Line Tag Color Description Trading Strategy
PDH 🟠 Orange Previous Day High Major Resistance — Breakout par Call Buy / Rejection par Put Buy
PDL ðŸ”ĩ Cyan Previous Day Low Major Support — Breakdown par Put Buy / Bounce par Call Buy
9:30 RES ðŸ”ī Bright Red 9:30 AM Opening High Morning Range Ceiling — Strong Intraday Resistance
9:30 SUP ðŸŸĒ Bright Green 9:30 AM Opening Low Morning Range Floor — Strong Intraday Support
CPR (TC/P/BC) ðŸŸĢ Purple / Blue Central Pivot Range TC ke upar Bullish, BC ke niche Bearish, beech me No Trade Zone
ðŸ”Ļ PIN BAR ðŸŸĒ Green / ðŸ”ī Red Rejection Candlestick Support par Hammer = Strong Buy | Resistance par Shooting Star = Strong Sell

ðŸ’ŧ TradingView Me Setup Karne Ka Tarika

  1. Neeche diye gaye Code Box se Copy Code button dabayein.
  2. TradingView kholein aur bottom me Pine Editor tab par click karein.
  3. Purana code delete karke naya V.12.0 Pro Max code paste karein.
  4. Save aur Add to Chart par click karein!
Sniper_Indicator_V12_ProMax.pine (Pine Script v5)
// ============================================================
// SNIPER ENTRY/EXIT — INDICATOR [Ashish Mishra V.12.0 - Pro Max Edition]
// Features: Indicator + Spot/Fut/VIX Dashboard + Nifty Pulse Dashboard + OI & Option Chain Engine
// V.10.0: Full Screen Extended Lines, 9:30 AM Fixed Day S/R Lock
// V.11.0: CPR Engine, Trap Detector, Synthetic PCR, User Controls
// V.12.0 Changes (PRO MAX EDITION):
//   [NEW] 📈 Signal History Line (BUY=Green dot / SELL=Red dot trail on price)
//   [OPT] Removed all duplicate request.security calls (merged into single fetch)
//   [OPT] Removed unused color variables and redundant switch blocks
//   [OPT] Unified theme variables across all dashboards
//   [OPT] Cleaned all dead-code branches and duplicate table renders
//   [FIX] Bull/Bear Score color logic unified via single helper
// ============================================================
//@version=5
indicator(
     title            = "Sniper Indicator [Ashish Mishra V.12.0 - Pro Max]",
     shorttitle       = "Sniper V.12.0 ProMax",
     overlay          = true,
     dynamic_requests = true,
     max_lines_count  = 500,
     max_labels_count = 500,
     max_boxes_count  = 50
     )

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 1 : GLOBAL DASHBOARD THEME  ═══════════════════
// ─────────────────────────────────────────────────────────────
dash_theme = input.string("Navy Blue", "ðŸŽĻ Dashboard Theme",
     options=["Navy Blue","Midnight","Custom"],
     group="ðŸŽĻ Dashboard Theme",
     tooltip="Navy Blue=Deep ocean | Midnight=Pure black | Custom=use per-group color picks")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 2 : CORE SETTINGS  ════════════════════════════
// ─────────────────────────────────────────────────────────────
atr_len      = input.int(14,     "ATR Length",                        group="⚙️ Core Settings")
rsi_len      = input.int(14,     "RSI Length",                        group="⚙️ Core Settings")
adx_len      = input.int(14,     "ADX Length",                        group="⚙️ Core Settings")
ema_fast     = input.int(9,      "Fast EMA Period",                   group="⚙️ Core Settings")
ema_slow     = input.int(21,     "Slow EMA Period",                   group="⚙️ Core Settings")
ema_200      = input.int(200,    "200 EMA Period",                    group="⚙️ Core Settings")
macd_fast    = input.int(12,     "MACD Fast",                         group="⚙️ Core Settings")
macd_slow    = input.int(26,     "MACD Slow",                         group="⚙️ Core Settings")
macd_signal  = input.int(9,      "MACD Signal",                       group="⚙️ Core Settings")
vol_ma_len   = input.int(20,     "Volume MA Length",                  group="⚙️ Core Settings")
dema_len     = input.int(50,     "LE-VAN-DO DEMA Len",                group="⚙️ Core Settings")
sigsensiviti = input.float(4.238,"Signal Sensitivity (LE-VAN-DO)",    group="⚙️ Core Settings", step=0.001)
smart_trail  = input.bool(true,  "Smart Trail (SL → Entry on TP1)",   group="⚙️ Core Settings")
show_sr      = input.bool(true,  "Show Dynamic Pivot S/R",            group="⚙️ Core Settings")
left_bars    = input.int(15,     "Pivot Left Bars",  group="⚙️ Core Settings", display=display.none)
right_bars   = input.int(15,     "Pivot Right Bars", group="⚙️ Core Settings", display=display.none)

// ── ADX FILTER ──
use_adx_filter = input.bool(true,  "🔰 Enable ADX Filter (Block Weak Trend)", group="⚙️ Core Settings")
min_adx        = input.float(25.0, "Minimum ADX Threshold", group="⚙️ Core Settings",
     step=1.0, minval=5.0, maxval=80.0,
     tooltip="Signal is blocked when ADX is below this value (weak trend filter)")

// ── RSI OB/OS LABELS ──
show_rsi_labels = input.bool(true, "📊 Show RSI OB/OS on Candles", group="⚙️ Core Settings")
rsi_ob_level    = input.int(70,    "RSI Overbought Level", group="⚙️ Core Settings", minval=60, maxval=90)
rsi_os_level    = input.int(30,    "RSI Oversold Level",   group="⚙️ Core Settings", minval=10, maxval=40)
rsi_ob_col      = input.color(color.new(color.red,  20), "OB Label Color", group="⚙️ Core Settings")
rsi_os_col      = input.color(color.new(color.lime, 20), "OS Label Color", group="⚙️ Core Settings")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 3 : V12 PRO FEATURE CONTROLS (ON / OFF)  ══════
// ─────────────────────────────────────────────────────────────
show_930_lines   = input.bool(true, "🔒 Show 9:30 AM Fixed Day S/R Lines",         group="ðŸ›Ą️ V12 Pro Feature Controls")
show_cpr_lines   = input.bool(true, "ðŸŽŊ Show CPR Lines (TC, Pivot, BC)",            group="ðŸ›Ą️ V12 Pro Feature Controls")
show_cpr_dash    = input.bool(true, "📊 Show CPR Classification in Dashboard",      group="ðŸ›Ą️ V12 Pro Feature Controls")
show_trap_labels = input.bool(true, "ðŸŠĪ Show Bull/Bear Trap Labels on Candles",     group="ðŸ›Ą️ V12 Pro Feature Controls")
show_syn_pcr     = input.bool(true, "📈 Show Synthetic PCR & Writer Sentiment",     group="ðŸ›Ą️ V12 Pro Feature Controls")
show_eos_eor     = input.bool(true, "ðŸŽŊ Show EOS (Support) & EOR (Resistance) Lines",group="ðŸ›Ą️ V12 Pro Feature Controls")
show_hist_line   = input.bool(true, "📈 Show Signal History Trail Line (V12 NEW)",  group="ðŸ›Ą️ V12 Pro Feature Controls",
     tooltip="Plots a colored dot/line trail of every BUY (green) and SELL (red) signal on the chart so you can review the history at a glance.")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 3B : PDH / PDL SETTINGS  ══════════════════════
// ─────────────────────────────────────────────────────────────
show_pdh_pdl    = input.bool(true,  "📌 Show PDH & PDL Lines",                  group="📌 PDH / PDL Settings",
     tooltip="PDH = Previous Day High | PDL = Previous Day Low\nYe dono important Support & Resistance levels hote hain.")
pdh_col         = input.color(color.new(#ff6d00, 0),  "PDH Line Color",          group="📌 PDH / PDL Settings")
pdl_col         = input.color(color.new(#00bcd4, 0),  "PDL Line Color",          group="📌 PDH / PDL Settings")
pdh_pdl_style_str = input.string("Dashed", "Line Style",
     options=["Solid","Dashed","Dotted"],              group="📌 PDH / PDL Settings")
pdh_pdl_width   = input.int(2,    "Line Width",  minval=1, maxval=5,             group="📌 PDH / PDL Settings")
pdh_pdl_lbl_sz_str = input.string("Small", "Label Size",
     options=["Tiny","Small","Normal","Large"],        group="📌 PDH / PDL Settings")

pdh_pdl_style = switch pdh_pdl_style_str
    "Solid"  => line.style_solid
    "Dashed" => line.style_dashed
    "Dotted" => line.style_dotted
    => line.style_dashed

pdh_pdl_lbl_sz = switch pdh_pdl_lbl_sz_str
    "Tiny"   => size.tiny
    "Small"  => size.small
    "Normal" => size.normal
    "Large"  => size.large
    => size.small

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 3C : PIN BAR S/R DETECTOR  ════════════════════
// ─────────────────────────────────────────────────────────────
show_pinbar_sr    = input.bool(true,  "ðŸ”Ļ Show Pin Bar @ S/R Labels",             group="ðŸ”Ļ Pin Bar S/R Rejection",
     tooltip="Detects Bullish Pin Bar (Hammer) at Support zones & Bearish Pin Bar (Shooting Star) at Resistance zones.")
pin_buf_mult      = input.float(0.35, "S/R Proximity Buffer (×ATR)",              group="ðŸ”Ļ Pin Bar S/R Rejection", step=0.05, minval=0.05, maxval=2.0)
pin_bull_col      = input.color(color.new(#00e676, 0), "Bullish Pin Bar Color",  group="ðŸ”Ļ Pin Bar S/R Rejection")
pin_bear_col      = input.color(color.new(#ff1744, 0), "Bearish Pin Bar Color",  group="ðŸ”Ļ Pin Bar S/R Rejection")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 4 : OPEN INTEREST & OPTION CHAIN  ═════════════
// ─────────────────────────────────────────────────────────────
show_oi_engine    = input.bool(true,  "📊 Enable OI & Option Chain Engine",             group="📊 OI & Option Chain Engine")
eos_eor_mult      = input.float(1.0,  "EOS/EOR ATR Buffer Multiplier",                  group="📊 OI & Option Chain Engine", step=0.1)
show_oi_labels    = input.bool(true,  "🏷️ Show OI Buildup Labels on Candles",           group="📊 OI & Option Chain Engine")
show_shift_labels = input.bool(true,  "🔄 Show WTT / WTB Shift Labels",                 group="📊 OI & Option Chain Engine")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 5 : TARGET & SL  ══════════════════════════════
// ─────────────────────────────────────────────────────────────
tp_mult1 = input.float(2.0, "TP1 Multiplier (×ATR)", group="ðŸŽŊ Target & SL Settings", step=0.1, minval=0.1)
tp_mult2 = input.float(4.0, "TP2 Multiplier (×ATR)", group="ðŸŽŊ Target & SL Settings", step=0.1, minval=0.1)
tp_mult3 = input.float(5.0, "TP3 Multiplier (×ATR)", group="ðŸŽŊ Target & SL Settings", step=0.1, minval=0.1)
sl_mult  = input.float(1.0, "SL Multiplier  (×ATR)", group="ðŸŽŊ Target & SL Settings", step=0.1, minval=0.1)

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 6 : DISPLAY OPTIONS  ══════════════════════════
// ─────────────────────────────────────────────────────────────
show_signals  = input.bool(true,  "Show BUY/SELL Labels",  group="👁️ Display Options")
show_tp_lines = input.bool(true,  "Show TP/SL Lines",      group="👁️ Display Options")
show_ema      = input.bool(true,  "Show EMA Lines",        group="👁️ Display Options")
show_zones    = input.bool(true,  "Show Bull/Bear Zone",   group="👁️ Display Options")
show_vwap     = input.bool(true,  "Show VWAP",             group="👁️ Display Options")
show_dema     = input.bool(true,  "Show LE-VAN-DO Line",   group="👁️ Display Options")
show_dema_bg  = input.bool(false, "Show DEMA Background",  group="👁️ Display Options")
dema_bg_trans = input.int(90,     "DEMA BG Transparency (0-100)", group="👁️ Display Options", minval=0, maxval=100)
show_st_line  = input.bool(true,  "Show Supertrend Line",  group="👁️ Display Options")
show_vsa_signals = input.bool(true, "Show VSA Lightning ⚡", group="👁️ Display Options")
show_mom_candles = input.bool(true, "Enable Momentum Candle Coloring", group="👁️ Display Options")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 7 : SNIPER DASHBOARD (RIGHT SIDE)  ════════════
// ─────────────────────────────────────────────────────────────
show_dash    = input.bool(true,          "Show Sniper Dashboard",   group="📊 Sniper Dashboard")
dash_pos_str = input.string("Top Right", "Position",
     options=["Top Right","Top Left","Middle Right","Middle Left","Bottom Right","Bottom Left"],
     group="📊 Sniper Dashboard")
dash_size_str = input.string("Tiny", "Text Size",
     options=["Tiny","Small","Normal","Large"], group="📊 Sniper Dashboard")
// Custom colors (used only when theme = Custom)
dash_bg_color   = input.color(color.new(#0d0d1a,   5),  "Background",       group="📊 Sniper Dashboard")
dash_head_bg    = input.color(color.new(#1a1a3e,  20),  "Header Background", group="📊 Sniper Dashboard")
dash_bull_color = input.color(color.new(color.lime, 0),  "Bull Color",        group="📊 Sniper Dashboard")
dash_bear_color = input.color(color.new(color.red,  0),  "Bear Color",        group="📊 Sniper Dashboard")
dash_neut_color = input.color(color.new(color.orange,0), "Neutral Color",     group="📊 Sniper Dashboard")

dash_pos = switch dash_pos_str
    "Top Right"    => position.top_right
    "Top Left"     => position.top_left
    "Middle Right" => position.middle_right
    "Middle Left"  => position.middle_left
    "Bottom Right" => position.bottom_right
    "Bottom Left"  => position.bottom_left
    => position.top_right

dash_txt_sz = switch dash_size_str
    "Tiny"   => size.tiny
    "Small"  => size.small
    "Normal" => size.normal
    "Large"  => size.large
    => size.small

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 8 : SPOT vs FUTURES DASHBOARD  ════════════════
// ─────────────────────────────────────────────────────────────
show_sf_dash = input.bool(true,              "Show Spot/Fut/VIX Dashboard",  group="📊 Spot vs Fut Dashboard")
spot_sym     = input.symbol("NSE:NIFTY",     "Spot Symbol",                 group="📊 Spot vs Fut Dashboard")
fut_sym      = input.symbol("NSE:NIFTY1!",   "Futures Symbol",              group="📊 Spot vs Fut Dashboard")
vix_sym      = input.symbol("NSE:INDIAVIX",  "IndiaVIX Symbol",             group="📊 Spot vs Fut Dashboard")
sf_pos_str   = input.string("Top Center",    "Position",
     options=["Top Center","Top Right","Top Left","Bottom Center","Bottom Right","Bottom Left"],
     group="📊 Spot vs Fut Dashboard")
sf_size_str  = input.string("Small", "Text Size", options=["Tiny","Small","Normal","Large"], group="📊 Spot vs Fut Dashboard")
sf_bg        = input.color(color.new(color.black, 10), "Background",  group="📊 Spot vs Fut Dashboard")
sf_header_bg = input.color(color.new(color.teal,  50), "Header Color", group="📊 Spot vs Fut Dashboard")
sf_text_col  = input.color(color.white,                "Text Color",   group="📊 Spot vs Fut Dashboard")
sf_border_col= input.color(color.gray,                 "Border Color", group="📊 Spot vs Fut Dashboard")
sf_bull_col  = input.color(color.lime,                 "Bull Color",   group="📊 Spot vs Fut Dashboard")
sf_bear_col  = input.color(color.red,                  "Bear Color",   group="📊 Spot vs Fut Dashboard")

sf_pos = switch sf_pos_str
    "Top Center"    => position.top_center
    "Top Right"     => position.top_right
    "Top Left"      => position.top_left
    "Bottom Center" => position.bottom_center
    "Bottom Right"  => position.bottom_right
    "Bottom Left"   => position.bottom_left
    => position.top_center

sf_sz = switch sf_size_str
    "Tiny"   => size.tiny
    "Small"  => size.small
    "Normal" => size.normal
    "Large"  => size.large
    => size.small

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 9 : MOMENTUM SETTINGS  ════════════════════════
// ─────────────────────────────────────────────────────────────
sqz_len = input.int(20, "Squeeze Length", group="🚀 Momentum Settings")
roc_len = input.int(10, "ROC Length",     group="🚀 Momentum Settings")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 10 : ZONE & EMA COLORS  ═══════════════════════
// ─────────────────────────────────────────────────────────────
bull_zone_col = input.color(color.new(color.green, 75), "Bull Zone Color", group="🌈 Zone & EMA Colors")
bear_zone_col = input.color(color.new(color.red,   75), "Bear Zone Color", group="🌈 Zone & EMA Colors")
ema_fast_col  = input.color(color.new(color.green, 40), "Fast EMA Color",  group="🌈 Zone & EMA Colors")
ema_slow_col  = input.color(color.new(color.red,   40), "Slow EMA Color",  group="🌈 Zone & EMA Colors")
ema_200_col   = input.color(color.new(color.purple, 0), "200 EMA Color",   group="🌈 Zone & EMA Colors")
vwap_col      = input.color(color.new(color.orange, 0), "VWAP Color",      group="🌈 Zone & EMA Colors")

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 11 : NIFTY PULSE DASHBOARD  ════════════════════
// ─────────────────────────────────────────────────────────────
show_nifty_pulse = input.bool(true,           "ðŸ‡ŪðŸ‡ģ Show Nifty Pulse Dashboard", group="ðŸ‡ŪðŸ‡ģ Nifty Pulse Dashboard")
nifty_pos_str    = input.string("Bottom Left", "Position",
     options=["Top Right","Top Left","Middle Right","Middle Left","Bottom Right","Bottom Left"],
     group="ðŸ‡ŪðŸ‡ģ Nifty Pulse Dashboard")
nifty_size_str   = input.string("Tiny", "Text Size", options=["Tiny","Small","Normal"], group="ðŸ‡ŪðŸ‡ģ Nifty Pulse Dashboard")
nifty_ema_len    = input.int(21, "EMA Length (Trend Filter)", group="ðŸ‡ŪðŸ‡ģ Nifty Pulse Dashboard", minval=5, maxval=100)

nifty_pos = switch nifty_pos_str
    "Top Right"    => position.top_right
    "Top Left"     => position.top_left
    "Middle Right" => position.middle_right
    "Middle Left"  => position.middle_left
    "Bottom Right" => position.bottom_right
    "Bottom Left"  => position.bottom_left
    => position.bottom_left

nifty_txt_sz = switch nifty_size_str
    "Tiny"   => size.tiny
    "Small"  => size.small
    "Normal" => size.normal
    => size.tiny

// ─────────────────────────────────────────────────────────────
// ══════  GROUP 12 : CONSOLIDATED DASHBOARD & SUPERTREND  ═════
// ─────────────────────────────────────────────────────────────
st_factor    = input.float(3.0, "Supertrend Factor",              group="ðŸ›Ą️ Consolidated Dashboard & Supertrend", step=0.1)
st_period    = input.int(10,    "Supertrend Period",              group="ðŸ›Ą️ Consolidated Dashboard & Supertrend")
show_con_dash= input.bool(false, "Show Consolidated Dashboard",    group="ðŸ›Ą️ Consolidated Dashboard & Supertrend",
     tooltip="Bottom Center wala bada dashboard. Chart clean rakhne ke liye default OFF hai.")
con_size_str = input.string("Small",         "Dashboard Text Size", group="ðŸ›Ą️ Consolidated Dashboard & Supertrend", options=["Tiny","Small","Normal","Large"])
con_pos_str  = input.string("Bottom Center", "Dashboard Position",  group="ðŸ›Ą️ Consolidated Dashboard & Supertrend",
     options=["Top Center","Top Right","Top Left","Bottom Center","Bottom Right","Bottom Left","Middle Right","Middle Left"])

con_txt_sz = switch con_size_str
    "Tiny"   => size.tiny
    "Small"  => size.small
    "Normal" => size.normal
    "Large"  => size.large
    => size.small

con_pos = switch con_pos_str
    "Top Center"    => position.top_center
    "Top Right"     => position.top_right
    "Top Left"      => position.top_left
    "Bottom Center" => position.bottom_center
    "Bottom Right"  => position.bottom_right
    "Bottom Left"   => position.bottom_left
    "Middle Right"  => position.middle_right
    "Middle Left"   => position.middle_left
    => position.bottom_center

// ─────────────────────────────────────────────────────────────
// ══════  UNIFIED THEME VARIABLES (single source of truth)  ═══
// ─────────────────────────────────────────────────────────────
theme_bg     = dash_theme == "Navy Blue" ? color.new(#051428,  5) : dash_theme == "Midnight" ? color.new(#000000,  5) : dash_bg_color
theme_head   = dash_theme == "Navy Blue" ? color.new(#0d2b52, 10) : dash_theme == "Midnight" ? color.new(#111111, 20) : dash_head_bg
theme_bull   = dash_bull_color
theme_bear   = dash_bear_color
theme_neut   = dash_neut_color
theme_border = color.new(color.gray, 60)
theme_frame  = dash_theme == "Midnight" ? color.new(color.gray, 50) : color.new(#ffd700, 20)

// ─────────────────────────────────────────────────────────────
// ══════  CORE CALCULATIONS  ══════════════════════════════════
// ─────────────────────────────────────────────────────────────
atr_val     = ta.atr(atr_len)
rsi         = ta.rsi(close, rsi_len)
[macd_line, sig_line, _] = ta.macd(close, macd_fast, macd_slow, macd_signal)
ema_f       = ta.ema(close, ema_fast)
ema_s       = ta.ema(close, ema_slow)
ema_200_val = ta.ema(close, ema_200)
vol_ma      = ta.sma(volume, vol_ma_len)
vwap_val    = ta.vwap(hlc3)
dema_val    = ta.hma(close, dema_len)
dema_color  = ta.change(dema_val) >= 0 ? color.new(color.green, 0) : color.new(color.red, 0)
dema_bg_c   = ta.change(dema_val) >= 0 ? color.new(color.green, dema_bg_trans) : color.new(color.red, dema_bg_trans)
bgcolor(show_dema_bg ? dema_bg_c : na, title="DEMA Background Color")

// ── ADX (manual, avoids DMI tuple overhead) ──
up      = ta.change(high)
dn      = -ta.change(low)
plusDM  = na(up) ? na : (up > dn  and up > 0  ? up  : 0)
minusDM = na(dn) ? na : (dn > up  and dn > 0  ? dn  : 0)
trur    = ta.rma(ta.tr, adx_len)
adx_plus  = fixnan(100 * ta.rma(plusDM,  adx_len) / trur)
adx_minus = fixnan(100 * ta.rma(minusDM, adx_len) / trur)
adx_val   = 100 * ta.rma(math.abs(adx_plus - adx_minus) / (adx_plus + adx_minus == 0 ? 1 : adx_plus + adx_minus), adx_len)
adx_ok    = not use_adx_filter or adx_val >= min_adx

// ── Supertrend ──
[st_val, st_dir] = ta.supertrend(st_factor, st_period)
st_bullish = st_dir < 0

// ── VWAP relative position ──
pvwap_str = close > vwap_val ? "ABOVE" : "BELOW"

// ── Volume ──
vol_str = volume > vol_ma * 1.5 ? "HIGH" : volume > vol_ma ? "NORMAL" : "LOW"

// ── 200 EMA Status ──
ema_200_str = close > ema_200_val ? "ABOVE" : "BELOW"

// ─────────────────────────────────────────────────────────────
// ══════  OPEN INTEREST ENGINE  ═══════════════════════════════
// ─────────────────────────────────────────────────────────────
f_oi_sym() =>
    string s = syminfo.tickerid
    if str.contains(syminfo.ticker, "NIFTY50") or syminfo.ticker == "NIFTY"
        s := "NSE:NIFTY1!_OI"
    else if str.contains(syminfo.ticker, "BANKNIFTY")
        s := "NSE:BANKNIFTY1!_OI"
    else if str.contains(syminfo.ticker, "FINNIFTY")
        s := "NSE:FINNIFTY1!_OI"
    else if str.contains(syminfo.ticker, "MIDCPNIFTY")
        s := "NSE:MIDCPNIFTY1!_OI"
    else
        s := syminfo.tickerid + "_OI"
    s

oi_raw = request.security(f_oi_sym(), timeframe.period, close, ignore_invalid_symbol=true)
cur_oi     = not na(oi_raw) and oi_raw > 0 ? oi_raw : request.security(syminfo.tickerid, timeframe.period, close, ignore_invalid_symbol=true)
has_oi     = show_oi_engine and not na(cur_oi) and cur_oi > 0
oi_chg     = has_oi ? ta.change(cur_oi) : 0.0
oi_chg_pct = has_oi and not na(cur_oi[1]) and cur_oi[1] > 0 ? (oi_chg / cur_oi[1]) * 100 : 0.0

oi_buildup_str = not has_oi ? "NO OI DATA" : close > close[1] and oi_chg > 0 ? "LONG BUILDUP" : close < close[1] and oi_chg > 0 ? "SHORT BUILDUP" : close < close[1] and oi_chg < 0 ? "LONG UNWINDING" : close > close[1] and oi_chg < 0 ? "SHORT COVERING" : "NEUTRAL"

oi_buildup_col = not has_oi ? color.gray : close > close[1] and oi_chg > 0 ? color.lime : close < close[1] and oi_chg > 0 ? color.red : close < close[1] and oi_chg < 0 ? color.orange : close > close[1] and oi_chg < 0 ? color.yellow : color.gray

// ─────────────────────────────────────────────────────────────
// ══════  SYNTHETIC PCR & WRITER SENTIMENT  ════════════════════
// ─────────────────────────────────────────────────────────────
var float syn_pcr = 1.00
if has_oi and oi_chg != 0
    float db = (close - vwap_val) / vwap_val * 100.0
    if close > vwap_val and oi_chg > 0
        syn_pcr := math.min(1.80, 1.00 + (oi_chg_pct / 40.0) + (db / 2.0))
    else if close < vwap_val and oi_chg > 0
        syn_pcr := math.max(0.40, 1.00 - (oi_chg_pct / 40.0) + (db / 2.0))
    else if close > vwap_val and oi_chg < 0
        syn_pcr := math.min(1.40, 1.00 + (db / 2.0))
    else if close < vwap_val and oi_chg < 0
        syn_pcr := math.max(0.50, 1.00 + (db / 2.0))

syn_pcr_str = not has_oi ? "N/A" : str.tostring(math.round(syn_pcr, 2))
syn_pcr_col = not has_oi ? color.gray : syn_pcr >= 1.15 ? color.lime : syn_pcr <= 0.85 ? color.red : color.orange

writer_sent_str = not has_oi ? "NO DATA" : syn_pcr >= 1.25 ? "PUT WRITERS CONTROL (BIG BULL)" : syn_pcr >= 1.05 ? "CALL WRITERS TRAPPED" : syn_pcr <= 0.75 ? "CALL WRITERS CONTROL (BIG BEAR)" : syn_pcr <= 0.95 ? "PUT WRITERS TRAPPED" : "WRITERS NEUTRAL"

writer_sent_col = not has_oi ? color.gray : syn_pcr >= 1.05 ? color.lime : syn_pcr <= 0.95 ? color.red : color.orange

// ─────────────────────────────────────────────────────────────
// ══════  CPR ENGINE  ══════════════════════════════════════════
// ─────────────────────────────────────────────────────────────
f_cpr_daily() =>
    _p  = (high[1] + low[1] + close[1]) / 3.0
    _bc = (high[1] + low[1]) / 2.0
    _tc = (_p - _bc) + _p
    [_p, _tc, _bc]

[cpr_p, cpr_tc, cpr_bc] = request.security(syminfo.tickerid, "D", f_cpr_daily())
cpr_width_pct = not na(cpr_p) and cpr_p > 0 ? (math.abs(cpr_tc - cpr_bc) / cpr_p) * 100.0 : 0.0
cpr_class_str = cpr_width_pct < 0.25 ? "NARROW CPR >> TRENDING DAY EXPECTED" : cpr_width_pct > 0.60 ? "WIDE CPR !! SIDEWAYS / RANGEBOUND DAY" : "AVERAGE CPR -- NORMAL DAY"
cpr_class_col = cpr_width_pct < 0.25 ? color.lime : cpr_width_pct > 0.60 ? color.red : color.yellow

plot(show_cpr_lines ? cpr_tc : na, "CPR TC",    color=color.new(color.purple, 20), linewidth=1)
plot(show_cpr_lines ? cpr_p  : na, "CPR Pivot", color=color.new(color.blue,   20), linewidth=2)
plot(show_cpr_lines ? cpr_bc : na, "CPR BC",    color=color.new(color.purple, 20), linewidth=1)

// ── PDH & PDL (Previous Day High / Low) ──
pdh = request.security(syminfo.tickerid, "D", high[1])
pdl = request.security(syminfo.tickerid, "D", low[1])

var line  l_pdh   = na
var line  l_pdl   = na
var label lbl_pdh = na
var label lbl_pdl = na

if barstate.islast
    line.delete(l_pdh)
    line.delete(l_pdl)
    label.delete(lbl_pdh)
    label.delete(lbl_pdl)

    if show_pdh_pdl and not na(pdh)
        l_pdh   := line.new(bar_index, pdh, bar_index + 1, pdh,
             xloc.bar_index, extend.both, pdh_col, pdh_pdl_style, pdh_pdl_width)
        lbl_pdh := label.new(bar_index + 2, pdh,
             "PDH  " + str.tostring(math.round(pdh, 2)),
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(pdh_col, 15), style=label.style_label_left,
             textcolor=color.white, size=pdh_pdl_lbl_sz)

    if show_pdh_pdl and not na(pdl)
        l_pdl   := line.new(bar_index, pdl, bar_index + 1, pdl,
             xloc.bar_index, extend.both, pdl_col, pdh_pdl_style, pdh_pdl_width)
        lbl_pdl := label.new(bar_index + 2, pdl,
             "PDL  " + str.tostring(math.round(pdl, 2)),
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(pdl_col, 15), style=label.style_label_left,
             textcolor=color.white, size=pdh_pdl_lbl_sz)

// ─────────────────────────────────────────────────────────────
// ══════  SQUEEZE MOMENTUM  ════════════════════════════════════
// ─────────────────────────────────────────────────────────────
bb_basis = ta.sma(close, sqz_len)
bb_dev   = 2.0 * ta.stdev(close, sqz_len)
kc_tr    = ta.rma(ta.tr, sqz_len)
sqz_on   = (bb_basis - bb_dev > bb_basis - 1.5 * kc_tr) and (bb_basis + bb_dev < bb_basis + 1.5 * kc_tr)
sqz_off  = (bb_basis - bb_dev < bb_basis - 1.5 * kc_tr) and (bb_basis + bb_dev > bb_basis + 1.5 * kc_tr)
sqz_str  = sqz_on ? "SQUEEZE ON ðŸ”ī" : sqz_off ? "FIRED 🚀" : "NO SQUEEZE"
sqz_col  = sqz_on ? color.new(color.red, 20) : sqz_off ? color.new(color.lime, 20) : color.new(color.gray, 60)

// ─────────────────────────────────────────────────────────────
// ══════  ROC MOMENTUM  ════════════════════════════════════════
// ─────────────────────────────────────────────────────────────
roc_val = ta.roc(close, roc_len)
roc_str = roc_val > 0.5 ? "HIGH BULL ⚡" : roc_val < -0.5 ? "HIGH BEAR ⚡" : roc_val > 0 ? "MILD BULL" : "MILD BEAR"
roc_col = roc_val > 0.5 ? color.lime : roc_val < -0.5 ? color.red : color.gray

// ─────────────────────────────────────────────────────────────
// ══════  VSA MOMENTUM  ════════════════════════════════════════
// ─────────────────────────────────────────────────────────────
is_vsa_bull = close > open and (close - open) > atr_val * 0.8 and volume > vol_ma * 1.5
is_vsa_bear = open > close and (open - close) > atr_val * 0.8 and volume > vol_ma * 1.5

// ─────────────────────────────────────────────────────────────
// ══════  MARKET PHASE  ════════════════════════════════════════
// ─────────────────────────────────────────────────────────────
atr_ma        = ta.sma(atr_val, 20)
high_atr      = atr_val > atr_ma
high_mom      = adx_val > 25
mkt_phase_str = high_mom and high_atr ? "SUPER TREND" : high_mom and not high_atr ? "SLOW TREND" : not high_mom and high_atr ? "CHOPPY MARKET" : "DEAD MARKET"
mkt_phase_bg  = high_mom and high_atr ? color.new(color.lime, 20) : high_mom and not high_atr ? color.new(color.green, 40) : not high_mom and high_atr ? color.new(color.red, 20) : color.new(color.gray, 60)
mkt_phase_txt = high_mom and high_atr     ? color.black : color.white

// ── MOMENTUM CANDLE COLORING ──
barcolor(show_mom_candles ?
     (is_vsa_bull ? color.new(#00FF00, 0) : close > open ? color.new(#2E8B57, 0) :
      is_vsa_bear ? color.new(#FF0000, 0) : open > close ? color.new(#8B0000, 0) : color.gray) : na,
     title="Momentum Candles")

// ─────────────────────────────────────────────────────────────
// ══════  SPOT / FUTURES DATA — single combined fetch  ════════
// ─────────────────────────────────────────────────────────────
f_get_sf(_len) =>
    _rsi = ta.rsi(close, _len)
    [_plus, _minus, _adx_v] = ta.dmi(_len, _len)
    [close, _rsi, _adx_v]

[spot_close, spot_rsi, spot_adx] = request.security(spot_sym, timeframe.period, f_get_sf(rsi_len))
[fut_close,  fut_rsi,  fut_adx]  = request.security(fut_sym,  timeframe.period, f_get_sf(rsi_len))
[vix_close,  vix_rsi,  vix_adx]  = request.security(vix_sym,  timeframe.period, f_get_sf(rsi_len))
daily_vix_chg                    = request.security(vix_sym, "D", (close - close[1]) / close[1] * 100)

sf_data_ok = not na(spot_close) and not na(fut_close)
sf_diff    = sf_data_ok ? fut_close - spot_close : 0.0

// ─────────────────────────────────────────────────────────────
// ══════  BULL / BEAR SCORE  ═══════════════════════════════════
// ─────────────────────────────────────────────────────────────
bull_pts = (rsi > 55 ? 1 : 0) + (macd_line > sig_line ? 1 : 0) + (ema_f > ema_s ? 1 : 0) +
           (close > vwap_val ? 1 : 0) + (close > close[5] ? 1 : 0) +
           (volume > vol_ma and close > open ? 1 : 0) + (adx_val > 25 ? 1 : 0) +
           (has_oi and oi_chg > 0 and close > close[1] ? 1 : 0)
bull_pct   = math.round(bull_pts / 8 * 100)
bear_pct   = 100 - bull_pct

market_bias = bull_pct >= 75 ? "STRONG BULL" : bull_pct >= 55 ? "BULL" : bull_pct <= 25 ? "STRONG BEAR" : bull_pct <= 45 ? "BEAR" : "NEUTRAL"

// ── Shared color helper ──
f_col(bull, bear) => bull ? theme_bull : bear ? theme_bear : theme_neut

// ─────────────────────────────────────────────────────────────
// ══════  QQE SIGNAL LOGIC  ════════════════════════════════════
// ─────────────────────────────────────────────────────────────
qqe_rsi_smooth = 3
qqe_wilders    = rsi_len * 2 - 1
qqe_ma_rsi     = ta.ema(rsi, qqe_rsi_smooth)
qqe_atr_rsi    = ta.ema(ta.ema(math.abs(qqe_ma_rsi[1] - qqe_ma_rsi), qqe_wilders), qqe_wilders) * sigsensiviti

var float qqe_longband  = 0.0
var float qqe_shortband = 0.0
var int   qqe_trend     = 0

qqe_nlong  = qqe_ma_rsi - qqe_atr_rsi
qqe_nshort = qqe_ma_rsi + qqe_atr_rsi

qqe_longband  := qqe_ma_rsi[1] > qqe_longband[1]  and qqe_ma_rsi > qqe_longband[1]  ? math.max(qqe_longband[1],  qqe_nlong)  : qqe_nlong
qqe_shortband := qqe_ma_rsi[1] < qqe_shortband[1] and qqe_ma_rsi < qqe_shortband[1] ? math.min(qqe_shortband[1], qqe_nshort) : qqe_nshort

qqe_trend := ta.cross(qqe_ma_rsi, qqe_shortband[1]) ? 1 : ta.cross(qqe_longband[1], qqe_ma_rsi) ? -1 : nz(qqe_trend[1], 1)
qqe_line   = qqe_trend == 1 ? qqe_longband : qqe_shortband

var int QQExlong  = 0
var int QQExshort = 0
QQExlong  := nz(QQExlong[1])
QQExshort := nz(QQExshort[1])
QQExlong  := qqe_line < qqe_ma_rsi ? QQExlong  + 1 : 0
QQExshort := qqe_line > qqe_ma_rsi ? QQExshort + 1 : 0

final_buy  = QQExlong  == 1 and adx_ok
final_sell = QQExshort == 1 and adx_ok
status_str = final_buy ? "BUY" : final_sell ? "SELL" : (use_adx_filter and adx_val < min_adx ? "ADX WEAK" : "WAIT")

// ─────────────────────────────────────────────────────────────
// ══════  AUTO S/R & EOS/EOR  ══════════════════════════════════
// ─────────────────────────────────────────────────────────────
ph = ta.pivothigh(high, left_bars, right_bars)
pl = ta.pivotlow(low,  left_bars, right_bars)

var float res_level = na
var float sup_level = na
if not na(ph)
    res_level := ph
if not na(pl)
    sup_level := pl

eos_level = not na(sup_level) ? sup_level - atr_val * eos_eor_mult : na
eor_level = not na(res_level) ? res_level + atr_val * eos_eor_mult : na

wtt_shift = ta.crossover(res_level, res_level[1])
wtb_shift = ta.crossunder(sup_level, sup_level[1])

// ─────────────────────────────────────────────────────────────
// ══════  TRAP & FALSE BREAKOUT DETECTOR  ══════════════════════
// ─────────────────────────────────────────────────────────────
is_bull_trap = ta.crossover(high,  res_level[1]) and (volume < vol_ma or (has_oi and oi_chg < 0) or close < open)
is_bear_trap = ta.crossunder(low,  sup_level[1]) and (volume < vol_ma or (has_oi and oi_chg < 0) or close > open)

if show_trap_labels
    if is_bull_trap
        label.new(bar_index, high, "BULL TRAP ðŸŠĪ\nFake Breakout!",
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(color.red, 10), style=label.style_label_down,
             textcolor=color.white, size=size.small)
    if is_bear_trap
        label.new(bar_index, low, "BEAR TRAP ðŸŠĪ\nFake Breakdown!",
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(color.green, 10), style=label.style_label_up,
             textcolor=color.white, size=size.small)

// ─────────────────────────────────────────────────────────────
// ══════  9:30 AM FIXED DAY RANGE ENGINE  ══════════════════════
// ─────────────────────────────────────────────────────────────
is_new_day = ta.change(time("D")) != 0
var float day_h930    = na
var float day_l930    = na
var float fix_res_930 = na
var float fix_sup_930 = na

if is_new_day
    day_h930    := high
    day_l930    := low
    fix_res_930 := high
    fix_sup_930 := low

if hour == 9 and minute <= 30
    day_h930    := math.max(nz(day_h930, high), high)
    day_l930    := math.min(nz(day_l930, low),  low)
    fix_res_930 := day_h930
    fix_sup_930 := day_l930

// ─────────────────────────────────────────────────────────────
// ══════  PIN BAR S/R REJECTION DETECTOR  ═════════════════════
// ─────────────────────────────────────────────────────────────
candle_rng   = high - low
candle_body  = math.abs(close - open)
candle_uw    = high - math.max(close, open)
candle_lw    = math.min(close, open) - low

// Bullish Pin Bar (Hammer): Lower Wick >= 55%, Body <= 35%, Upper Wick <= 25%
is_bull_pin = candle_rng > 0 and (candle_lw >= candle_rng * 0.55) and (candle_body <= candle_rng * 0.35) and (candle_uw <= candle_rng * 0.25)

// Bearish Pin Bar (Shooting Star): Upper Wick >= 55%, Body <= 35%, Lower Wick <= 25%
is_bear_pin = candle_rng > 0 and (candle_uw >= candle_rng * 0.55) and (candle_body <= candle_rng * 0.35) and (candle_lw <= candle_rng * 0.25)

pin_buf = atr_val * pin_buf_mult

// Support rejection test (Low tests level, Close holds above or near level)
near_sup = (not na(sup_level)   and low <= sup_level + pin_buf   and close >= sup_level - pin_buf) or
           (not na(pdl)         and low <= pdl + pin_buf         and close >= pdl - pin_buf) or
           (not na(fix_sup_930) and low <= fix_sup_930 + pin_buf and close >= fix_sup_930 - pin_buf) or
           (not na(cpr_bc)      and low <= cpr_bc + pin_buf      and close >= cpr_bc - pin_buf) or
           (not na(cpr_p)       and low <= cpr_p + pin_buf       and close >= cpr_p - pin_buf)

// Resistance rejection test (High tests level, Close stays below or near level)
near_res = (not na(res_level)   and high >= res_level - pin_buf   and close <= res_level + pin_buf) or
           (not na(pdh)         and high >= pdh - pin_buf         and close <= pdh + pin_buf) or
           (not na(fix_res_930) and high >= fix_res_930 - pin_buf and close <= fix_res_930 + pin_buf) or
           (not na(cpr_tc)      and high >= cpr_tc - pin_buf      and close <= cpr_tc + pin_buf) or
           (not na(cpr_p)       and high >= cpr_p - pin_buf       and close <= cpr_p + pin_buf)

bull_pin_sup = is_bull_pin and near_sup
bear_pin_res = is_bear_pin and near_res

if show_pinbar_sr
    if bull_pin_sup
        label.new(bar_index, low, "ðŸ”Ļ PIN BAR\n@ Support",
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(pin_bull_col, 10), style=label.style_label_up,
             textcolor=color.white, size=size.small)
    if bear_pin_res
        label.new(bar_index, high, "⭐ PIN BAR\n@ Resistance",
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(pin_bear_col, 10), style=label.style_label_down,
             textcolor=color.white, size=size.small)

var line  l_res       = na
var line  l_sup       = na
var line  l_eor       = na
var line  l_eos       = na
var line  l_res_930   = na
var line  l_sup_930   = na
var label lbl_res     = na
var label lbl_sup     = na
var label lbl_eor     = na
var label lbl_eos     = na
var label lbl_res_930 = na
var label lbl_sup_930 = na

if barstate.islast
    line.delete(l_res)
    line.delete(l_sup)
    line.delete(l_eor)
    line.delete(l_eos)
    line.delete(l_res_930)
    line.delete(l_sup_930)
    label.delete(lbl_res)
    label.delete(lbl_sup)
    label.delete(lbl_eor)
    label.delete(lbl_eos)
    label.delete(lbl_res_930)
    label.delete(lbl_sup_930)

    if show_sr and not na(res_level)
        l_res   := line.new(bar_index, res_level, bar_index + 1, res_level,
             xloc.bar_index, extend.both, color.new(color.red, 0), line.style_solid, 2)
        lbl_res := label.new(bar_index + 2, res_level, "RES  " + str.tostring(math.round(res_level, 2)),
             xloc=xloc.bar_index, yloc=yloc.price, color=color.new(color.red, 15),
             style=label.style_label_left, textcolor=color.white, size=size.small)

    if show_sr and not na(sup_level)
        l_sup   := line.new(bar_index, sup_level, bar_index + 1, sup_level,
             xloc.bar_index, extend.both, color.new(color.lime, 0), line.style_solid, 2)
        lbl_sup := label.new(bar_index + 2, sup_level, "SUP  " + str.tostring(math.round(sup_level, 2)),
             xloc=xloc.bar_index, yloc=yloc.price, color=color.new(#00c853, 15),
             style=label.style_label_left, textcolor=color.white, size=size.small)

    if show_eos_eor and not na(eor_level)
        l_eor   := line.new(bar_index, eor_level, bar_index + 1, eor_level,
             xloc.bar_index, extend.both, color.new(color.red, 20), line.style_dashed, 2)
        lbl_eor := label.new(bar_index + 2, eor_level, "EOR  " + str.tostring(math.round(eor_level, 2)),
             xloc=xloc.bar_index, yloc=yloc.price, color=color.new(color.red, 25),
             style=label.style_label_left, textcolor=color.white, size=size.small)

    if show_eos_eor and not na(eos_level)
        l_eos   := line.new(bar_index, eos_level, bar_index + 1, eos_level,
             xloc.bar_index, extend.both, color.new(color.lime, 20), line.style_dashed, 2)
        lbl_eos := label.new(bar_index + 2, eos_level, "EOS  " + str.tostring(math.round(eos_level, 2)),
             xloc=xloc.bar_index, yloc=yloc.price, color=color.new(#00c853, 25),
             style=label.style_label_left, textcolor=color.white, size=size.small)

    if show_930_lines and not na(fix_res_930)
        l_res_930   := line.new(bar_index, fix_res_930, bar_index + 1, fix_res_930,
             xloc.bar_index, extend.both, color.new(#ff1744, 0), line.style_solid, 3)
        lbl_res_930 := label.new(bar_index + 2, fix_res_930, "9:30 RES  " + str.tostring(math.round(fix_res_930, 2)),
             xloc=xloc.bar_index, yloc=yloc.price, color=color.new(#ff1744, 15),
             style=label.style_label_left, textcolor=color.white, size=size.small)

    if show_930_lines and not na(fix_sup_930)
        l_sup_930   := line.new(bar_index, fix_sup_930, bar_index + 1, fix_sup_930,
             xloc.bar_index, extend.both, color.new(#00e676, 0), line.style_solid, 3)
        lbl_sup_930 := label.new(bar_index + 2, fix_sup_930, "9:30 SUP  " + str.tostring(math.round(fix_sup_930, 2)),
             xloc=xloc.bar_index, yloc=yloc.price, color=color.new(#00e676, 15),
             style=label.style_label_left, textcolor=color.white, size=size.small)

// ─────────────────────────────────────────────────────────────
// ══════  ENTRY / SL / TP STORAGE & SMART TRAIL  ══════════════
// ─────────────────────────────────────────────────────────────
var float entry_p = na
var float sl_p    = na
var float tp1_p   = na
var float tp2_p   = na
var float tp3_p   = na
var bool  is_long = false

var string last_conf_str = "---"
var color  last_conf_col = color.gray

if final_buy
    entry_p       := close
    sl_p          := low  - atr_val * sl_mult
    tp1_p         := close + atr_val * tp_mult1
    tp2_p         := close + atr_val * tp_mult2
    tp3_p         := close + atr_val * tp_mult3
    is_long       := true
    float sc = 30.0 +
         (close > ema_200_val ? 15.0 : 0) + (macd_line > sig_line ? 15.0 : 0) +
         (rsi > 50 ? 10.0 : 0) + (st_bullish ? 15.0 : 0) +
         (adx_val >= min_adx ? 10.0 : 0) + (has_oi and oi_chg > 0 ? 5.0 : 0)
    last_conf_str := str.tostring(sc) + "% " + (sc >= 80 ? "STRONG" : sc >= 60 ? "MEDIUM" : "WEAK")
    last_conf_col := sc >= 80 ? color.lime : sc >= 60 ? color.orange : color.red

if final_sell
    entry_p       := close
    sl_p          := high + atr_val * sl_mult
    tp1_p         := close - atr_val * tp_mult1
    tp2_p         := close - atr_val * tp_mult2
    tp3_p         := close - atr_val * tp_mult3
    is_long       := false
    float sc = 30.0 +
         (close < ema_200_val ? 15.0 : 0) + (macd_line < sig_line ? 15.0 : 0) +
         (rsi < 50 ? 10.0 : 0) + (not st_bullish ? 15.0 : 0) +
         (adx_val >= min_adx ? 10.0 : 0) + (has_oi and oi_chg > 0 ? 5.0 : 0)
    last_conf_str := str.tostring(sc) + "% " + (sc >= 80 ? "STRONG" : sc >= 60 ? "MEDIUM" : "WEAK")
    last_conf_col := sc >= 80 ? color.lime : sc >= 60 ? color.orange : color.red

// Smart Trail
var bool risk_free = false
if final_buy or final_sell
    risk_free := false
if smart_trail and not risk_free
    if is_long     and high >= tp1_p
        sl_p      := entry_p
        risk_free := true
    if not is_long and low  <= tp1_p
        sl_p      := entry_p
        risk_free := true

// ─────────────────────────────────────────────────────────────
// ══════  TP/SL VISUAL LINES & BOXES  ══════════════════════════
// ─────────────────────────────────────────────────────────────
countBull  = ta.barssince(final_buy)
countBear  = ta.barssince(final_sell)
bar_offset = is_long ? nz(countBull) : nz(countBear)

if show_tp_lines and not na(entry_p)
    x1  = bar_index - bar_offset
    x2  = bar_index + 25
    xlb = bar_index + 26

    l_s  = line.new(x1, sl_p,    x2, sl_p,    xloc.bar_index, extend.none, color.new(color.red,   0), line.style_solid,  3)
    l_e  = line.new(x1, entry_p, x2, entry_p, xloc.bar_index, extend.none, color.new(color.white,40), line.style_dotted, 2)
    l_t1 = line.new(x1, tp1_p,  x2, tp1_p,   xloc.bar_index, extend.none, color.new(color.lime,  0), line.style_solid,  2)
    l_t2 = line.new(x1, tp2_p,  x2, tp2_p,   xloc.bar_index, extend.none, color.new(color.lime, 25), line.style_dashed, 1)
    l_t3 = line.new(x1, tp3_p,  x2, tp3_p,   xloc.bar_index, extend.none, color.new(color.lime, 50), line.style_dotted, 1)
    line.delete(l_s[1])
    line.delete(l_e[1])
    line.delete(l_t1[1])
    line.delete(l_t2[1])
    line.delete(l_t3[1])

    rb = box.new(x1, math.max(sl_p, entry_p), x2, math.min(sl_p, entry_p),
         border_color=color.new(color.red,  100), bgcolor=color.new(color.red,  87))
    pb = box.new(x1, math.max(entry_p, tp1_p), x2, math.min(entry_p, tp1_p),
         border_color=color.new(color.lime, 100), bgcolor=color.new(color.lime, 87))
    box.delete(rb[1])
    box.delete(pb[1])

    entry_icon = is_long ? "LONG  " : "SHORT "
    entry_bgc  = is_long ? color.new(#1a4a2e, 10) : color.new(#4a1a1a, 10)

    lb_sl = label.new(xlb, sl_p,    "SL   " + str.tostring(sl_p,    "#.##"), xloc.bar_index, yloc.price, color.new(color.red,   5), label.style_label_left, color.white, size.normal)
    lb_e  = label.new(xlb, entry_p, entry_icon + str.tostring(entry_p,"#.##"),xloc.bar_index, yloc.price, entry_bgc,                label.style_label_left, color.white, size.normal)
    lb_t1 = label.new(xlb, tp1_p,  "TP1  " + str.tostring(tp1_p,  "#.##"), xloc.bar_index, yloc.price, color.new(color.lime,  5), label.style_label_left, color.black, size.normal)
    lb_t2 = label.new(xlb, tp2_p,  "TP2  " + str.tostring(tp2_p,  "#.##"), xloc.bar_index, yloc.price, color.new(color.green,15), label.style_label_left, color.white, size.small)
    lb_t3 = label.new(xlb, tp3_p,  "TP3  " + str.tostring(tp3_p,  "#.##"), xloc.bar_index, yloc.price, color.new(color.green,35), label.style_label_left, color.white, size.small)
    label.delete(lb_sl[1])
    label.delete(lb_e[1])
    label.delete(lb_t1[1])
    label.delete(lb_t2[1])
    label.delete(lb_t3[1])

// ─────────────────────────────────────────────────────────────
// ══════  BUY / SELL & OI LABELS  ══════════════════════════════
// ─────────────────────────────────────────────────────────────
if show_signals
    if final_buy
        lbl_txt = "BUY\n" + str.tostring(close, "#.##") + (has_oi ? "\n(" + oi_buildup_str + ")" : "")
        label.new(bar_index, low, lbl_txt,
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(#00c853, 0), style=label.style_label_up,
             textcolor=color.white, size=size.normal)
    if final_sell
        lbl_txt = "SELL\n" + str.tostring(close, "#.##") + (has_oi ? "\n(" + oi_buildup_str + ")" : "")
        label.new(bar_index, high, lbl_txt,
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(#d32f2f, 0), style=label.style_label_down,
             textcolor=color.white, size=size.normal)

if show_shift_labels
    if wtt_shift
        label.new(bar_index, high, "WTT ↗️\nRes Shift Top",
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(color.purple, 10), style=label.style_label_down, textcolor=color.white, size=size.small)
    if wtb_shift
        label.new(bar_index, low, "WTB ↘️\nSup Shift Bottom",
             xloc=xloc.bar_index, yloc=yloc.price,
             color=color.new(color.orange, 10), style=label.style_label_up, textcolor=color.white, size=size.small)

// ── VSA Lightning ──
plotshape(show_vsa_signals and is_vsa_bull ? low  : na, "VSA Bull", shape.labelup,   location.belowbar, color.new(color.lime, 0), text="⚡", textcolor=color.black, size=size.tiny)
plotshape(show_vsa_signals and is_vsa_bear ? high : na, "VSA Bear", shape.labeldown, location.abovebar, color.new(color.red,  0), text="⚡", textcolor=color.white, size=size.tiny)

// ── RSI OB / OS Labels ──
if show_rsi_labels
    if rsi >= rsi_ob_level and rsi[1] < rsi_ob_level
        label.new(bar_index, high, "OB\n" + str.tostring(math.round(rsi, 1)),
             xloc=xloc.bar_index, yloc=yloc.price, color=rsi_ob_col,
             style=label.style_label_down, textcolor=color.white, size=size.small)
    if rsi <= rsi_os_level and rsi[1] > rsi_os_level
        label.new(bar_index, low, "OS\n" + str.tostring(math.round(rsi, 1)),
             xloc=xloc.bar_index, yloc=yloc.price, color=rsi_os_col,
             style=label.style_label_up, textcolor=color.black, size=size.small)

// ─────────────────────────────────────────────────────────────
// ══════  [V12 NEW] SIGNAL HISTORY TRAIL LINE  ════════════════
// ─────────────────────────────────────────────────────────────
// Plots a colored dot at the close price of every BUY/SELL signal bar,
// creating a visual audit trail of past signals directly on the price chart.
hist_buy_col  = color.new(color.lime,  0)
hist_sell_col = color.new(color.red,   0)
hist_wait_col = color.new(color.gray, 80)

plot(show_hist_line and final_buy  ? close : na, "Signal History BUY",  color=hist_buy_col,  style=plot.style_circles, linewidth=4)
plot(show_hist_line and final_sell ? close : na, "Signal History SELL", color=hist_sell_col, style=plot.style_circles, linewidth=4)

// Connecting trail line (faded) between signals
var float last_sig_price = na
var color last_sig_color = hist_wait_col
if final_buy
    last_sig_price := close
    last_sig_color  := hist_buy_col
if final_sell
    last_sig_price := close
    last_sig_color  := hist_sell_col
plot(show_hist_line and not na(last_sig_price) ? last_sig_price : na,
     "Signal Trail", color=color.new(last_sig_color, 70), style=plot.style_stepline, linewidth=1)

// ─────────────────────────────────────────────────────────────
// ══════  EMA PLOTS & ZONE  ════════════════════════════════════
// ─────────────────────────────────────────────────────────────
p_ema_f   = plot(show_ema ? ema_f       : na, "Fast EMA",       color=ema_fast_col, linewidth=1)
p_ema_s   = plot(show_ema ? ema_s       : na, "Slow EMA",       color=ema_slow_col, linewidth=1)
p_ema_200 = plot(show_ema ? ema_200_val : na, "200 EMA",        color=ema_200_col,  linewidth=2)
fill(p_ema_f, p_ema_s,
     color=show_zones ? (ema_f > ema_s ? bull_zone_col : bear_zone_col) : na,
     title="EMA Zone")
plot(show_vwap    ? vwap_val : na, "VWAP",           color=vwap_col,                      linewidth=2)
plot(show_dema    ? dema_val : na, "LE-VAN-DO Line",  color=dema_color,                    linewidth=2)
plot(show_st_line ? st_val   : na, "Supertrend Line", color=st_dir < 0 ? color.lime : color.red, linewidth=2)

// ─────────────────────────────────────────────────────────────
// ══════  SPOT vs FUTURES DASHBOARD  ══════════════════════════
// ─────────────────────────────────────────────────────────────
if show_sf_dash and barstate.islast
    var table sf_dash = table.new(sf_pos, 5, 4, bgcolor=sf_bg, border_color=sf_border_col, border_width=1, frame_color=sf_border_col, frame_width=1)

    table.cell(sf_dash, 0, 0, "SYMBOL", text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_header_bg, text_halign=text.align_center)
    table.cell(sf_dash, 1, 0, "PRICE",  text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_header_bg, text_halign=text.align_center)
    table.cell(sf_dash, 2, 0, "RSI",    text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_header_bg, text_halign=text.align_center)
    table.cell(sf_dash, 3, 0, "ADX",    text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_header_bg, text_halign=text.align_center)
    table.cell(sf_dash, 4, 0, "TREND",  text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_header_bg, text_halign=text.align_center)

    if sf_data_ok
        spot_rsi_col = nz(spot_rsi) > 70 ? sf_bull_col : nz(spot_rsi) < 30 ? sf_bear_col : sf_text_col
        fut_rsi_col  = nz(fut_rsi)  > 70 ? sf_bull_col : nz(fut_rsi)  < 30 ? sf_bear_col : sf_text_col
        spot_adx_col = nz(spot_adx) > 25 ? sf_bull_col : nz(spot_adx) < 20 ? sf_bear_col : sf_text_col
        fut_adx_col  = nz(fut_adx)  > 25 ? sf_bull_col : nz(fut_adx)  < 20 ? sf_bear_col : sf_text_col

        spot_ema21  = ta.ema(nz(spot_close), 21)
        fut_ema21   = ta.ema(nz(fut_close),  21)
        spot_trend  = nz(spot_close) > spot_ema21 ? "BULL ▲" : "BEAR ▼"
        fut_trend   = nz(fut_close)  > fut_ema21  ? "BULL ▲" : "BEAR ▼"

        table.cell(sf_dash, 0, 1, "📍 SPOT",  text_color=sf_text_col,     text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_left)
        table.cell(sf_dash, 1, 1, str.tostring(spot_close, "#.##"), text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 2, 1, str.tostring(spot_rsi, "#.#"),   text_color=spot_rsi_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 3, 1, str.tostring(spot_adx, "#.#"),   text_color=spot_adx_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 4, 1, spot_trend, text_color=spot_trend == "BULL ▲" ? sf_bull_col : sf_bear_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)

        diff_sign = sf_diff >= 0 ? "+" : ""
        table.cell(sf_dash, 0, 2, "🚀 FUT",   text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_left)
        table.cell(sf_dash, 1, 2, str.tostring(fut_close,"#.##") + " (" + diff_sign + str.tostring(sf_diff,"#.##") + ")", text_color=sf_diff>=0?sf_bull_col:sf_bear_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 2, 2, str.tostring(fut_rsi, "#.#"),  text_color=fut_rsi_col,                              text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 3, 2, str.tostring(fut_adx, "#.#"),  text_color=fut_adx_col,                              text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 4, 2, fut_trend,  text_color=fut_trend=="BULL ▲"?sf_bull_col:sf_bear_col,                text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)

        vix_ema21    = ta.ema(nz(vix_close), 21)
        vix_trend    = nz(vix_close) > vix_ema21 ? "RISING ▲" : "FALLING ▼"
        vix_tr_col   = nz(vix_close) > vix_ema21 ? sf_bear_col : sf_bull_col
        vix_sign     = nz(daily_vix_chg) >= 0 ? "+" : ""
        vix_chg_col  = nz(daily_vix_chg) >= 0 ? sf_bear_col : sf_bull_col
        vix_rsi_col  = nz(vix_rsi) > 60 ? sf_bear_col : nz(vix_rsi) < 40 ? sf_bull_col : sf_text_col
        vix_adx_col  = nz(vix_adx) > 25 ? color.orange : sf_text_col

        table.cell(sf_dash, 0, 3, "ðŸ‡ŪðŸ‡ģ VIX",  text_color=sf_text_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_left)
        table.cell(sf_dash, 1, 3, str.tostring(vix_close,"#.##") + " (" + vix_sign + str.tostring(daily_vix_chg,"#.##") + "%)", text_color=vix_chg_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 2, 3, str.tostring(vix_rsi,"#.#"), text_color=vix_rsi_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 3, 3, str.tostring(vix_adx,"#.#"), text_color=vix_adx_col, text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)
        table.cell(sf_dash, 4, 3, vix_trend,  text_color=vix_tr_col,   text_size=sf_sz, bgcolor=sf_bg, text_halign=text.align_center)

// ─────────────────────────────────────────────────────────────
// ══════  MTF TREND (single 144-EMA bull flag per TF)  ════════
// ─────────────────────────────────────────────────────────────
mtf_ema_len  = 144
f_mtf() => close > ta.ema(close, mtf_ema_len)

trend_1m  = request.security(syminfo.tickerid, "1",   f_mtf())
trend_3m  = request.security(syminfo.tickerid, "3",   f_mtf())
trend_5m  = request.security(syminfo.tickerid, "5",   f_mtf())
trend_15m = request.security(syminfo.tickerid, "15",  f_mtf())
trend_1h  = request.security(syminfo.tickerid, "60",  f_mtf())
trend_4h  = request.security(syminfo.tickerid, "240", f_mtf())

// ─────────────────────────────────────────────────────────────
// ══════  SNIPER DASHBOARD  ════════════════════════════════════
// ─────────────────────────────────────────────────────────────
if show_dash and barstate.islast
    var table dash = table.new(dash_pos, 2, 33, bgcolor=theme_bg, border_color=theme_border, border_width=1, frame_color=theme_frame, frame_width=2)

    table.cell(dash, 0, 0, "SNIPER DASHBOARD", text_color=color.yellow, bgcolor=theme_head, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 0, "V.12.0 PRO MAX",   text_color=color.white,  bgcolor=theme_head, text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 1, "─── Market Snapshot ───", text_color=color.white, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 1, "", bgcolor=theme_bg, text_size=dash_txt_sz)

    b_bg = market_bias == "STRONG BULL" ? color.new(color.green, 20) : market_bias == "BULL" ? color.new(color.lime, 40) : market_bias == "STRONG BEAR" ? color.new(color.red, 20) : market_bias == "BEAR" ? color.new(color.orange, 40) : color.new(color.gray, 20)
    table.cell(dash, 0, 2, "Market Bias",  text_color=color.white,  bgcolor=color.new(color.navy,30), text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 2, market_bias,    text_color=color.white,  bgcolor=b_bg,                     text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 3, "CPR Classification", text_color=color.yellow, bgcolor=theme_bg,                                                              text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 3, show_cpr_dash ? cpr_class_str : "DISABLED",   text_color=show_cpr_dash ? color.black : color.gray, bgcolor=show_cpr_dash ? cpr_class_col : theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 4, "Market Phase", text_color=color.white, bgcolor=color.new(color.navy,30), text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 4, mkt_phase_str,  text_color=mkt_phase_txt, bgcolor=mkt_phase_bg,           text_size=dash_txt_sz, text_halign=text.align_center)

    s_bg  = status_str == "BUY" ? color.new(color.lime,20) : status_str == "SELL" ? color.new(color.red,20) : status_str == "ADX WEAK" ? color.new(color.orange,20) : color.new(color.gray,50)
    s_txt = status_str == "BUY" ? color.black : color.white
    table.cell(dash, 0, 5, "Signal Status", text_color=color.white, bgcolor=color.new(color.navy,30), text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 5, status_str,      text_color=s_txt,       bgcolor=s_bg,                     text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 6, "Bull Score", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 6, str.tostring(bull_pct) + "%", text_color=color.lime, bgcolor=theme_bg,       text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 7, "Bear Score", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 7, str.tostring(bear_pct) + "%", text_color=color.red,  bgcolor=theme_bg,       text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 8, "─── OI & PCR Engine ───", text_color=color.yellow, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 8, "", bgcolor=theme_bg, text_size=dash_txt_sz)

    table.cell(dash, 0, 9,  "OI Buildup",             text_color=color.gray,     bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 9,  oi_buildup_str,            text_color=oi_buildup_col, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 10, "Synthetic PCR",           text_color=color.gray,     bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 10, show_syn_pcr ? syn_pcr_str : "OFF",         text_color=show_syn_pcr?syn_pcr_col:color.gray,      bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 11, "Option Writer Sentiment", text_color=color.gray,     bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 11, show_syn_pcr ? writer_sent_str : "OFF",     text_color=show_syn_pcr?writer_sent_col:color.gray,  bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)

    oi_chg_str = has_oi ? (oi_chg >= 0 ? "+" : "") + str.tostring(math.round(oi_chg_pct,2)) + "%" : "N/A"
    table.cell(dash, 0, 12, "OI Change",       text_color=color.gray,                              bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 12, oi_chg_str,        text_color=oi_chg>=0?theme_bull:theme_bear,         bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 13, "─── Key Metrics ───", text_color=color.white, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 13, "", bgcolor=theme_bg, text_size=dash_txt_sz)

    rsi_zone_str = rsi >= rsi_ob_level ? "OVERBOUGHT ðŸ”ī" : rsi <= rsi_os_level ? "OVERSOLD ðŸŸĒ" : "NEUTRAL"
    rsi_zone_col = rsi >= rsi_ob_level ? theme_bear : rsi <= rsi_os_level ? theme_bull : color.gray
    table.cell(dash, 0, 14, "RSI (" + str.tostring(rsi_len) + ")", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 14, str.tostring(math.round(rsi,1)),        text_color=f_col(rsi>55,rsi<45),        bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 15, "RSI Zone",    text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 15, rsi_zone_str,  text_color=rsi_zone_col, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)

    adx_fstr = use_adx_filter ? (adx_val>=min_adx?"ACTIVE ✅":"WEAK ⚠️") : "OFF"
    adx_fcol  = use_adx_filter ? (adx_val>=min_adx?theme_bull:color.orange) : color.gray
    table.cell(dash, 0, 16, "ADX Power",  text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 16, str.tostring(math.round(adx_val,1)), text_color=f_col(adx_val>30,adx_val<20), bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 17, "ADX Filter", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 17, adx_fstr,     text_color=adx_fcol,   bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 18, "ATR (" + str.tostring(atr_len) + ")", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 18, str.tostring(math.round(atr_val,2)),    text_color=color.orange, bgcolor=theme_bg,text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 19, "Vol Status",  text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 19, vol_str,       text_color=f_col(vol_str=="HIGH",vol_str=="LOW"), bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 20, "─── Trend Lines ───", text_color=color.white, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 20, "", bgcolor=theme_bg, text_size=dash_txt_sz)

    table.cell(dash, 0, 21, "200 EMA",    text_color=color.gray,   bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 21, ema_200_str,  text_color=ema_200_str=="ABOVE"?theme_bull:theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 22, "VWAP Status",text_color=color.gray,   bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 22, pvwap_str,    text_color=f_col(pvwap_str=="ABOVE",pvwap_str=="BELOW"), bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    dt_str = ta.change(dema_val)>=0?"BULL ▲":"BEAR ▼"
    table.cell(dash, 0, 23, "DEMA Trend", text_color=color.gray,   bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 23, dt_str,       text_color=ta.change(dema_val)>=0?theme_bull:theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)


    table.cell(dash, 0, 24, "─── MTF Trend ───", text_color=color.white, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 24, "", bgcolor=theme_bg, text_size=dash_txt_sz)

    table.cell(dash, 0, 25, "1 Min",  text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 25, trend_1m  ? "BULL ▲" : "BEAR ▼", text_color=trend_1m  ? theme_bull : theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 26, "3 Min",  text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 26, trend_3m  ? "BULL ▲" : "BEAR ▼", text_color=trend_3m  ? theme_bull : theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 27, "5 Min",  text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 27, trend_5m  ? "BULL ▲" : "BEAR ▼", text_color=trend_5m  ? theme_bull : theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 28, "15 Min", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 28, trend_15m ? "BULL ▲" : "BEAR ▼", text_color=trend_15m ? theme_bull : theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 29, "1 Hour", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 29, trend_1h  ? "BULL ▲" : "BEAR ▼", text_color=trend_1h  ? theme_bull : theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 30, "4 Hour", text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 30, trend_4h  ? "BULL ▲" : "BEAR ▼", text_color=trend_4h  ? theme_bull : theme_bear, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)

    table.cell(dash, 0, 31, "Squeeze",  text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 31, sqz_str,    text_color=sqz_str=="NO SQUEEZE"?color.gray:color.white, bgcolor=sqz_col, text_size=dash_txt_sz, text_halign=text.align_center)
    table.cell(dash, 0, 32, "ROC Speed",text_color=color.gray, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_left)
    table.cell(dash, 1, 32, roc_str + " (" + str.tostring(math.round(roc_val,2)) + "%)", text_color=roc_col, bgcolor=theme_bg, text_size=dash_txt_sz, text_halign=text.align_center)

// ─────────────────────────────────────────────────────────────
// ══════  NIFTY PULSE DASHBOARD  ═══════════════════════════════
// ─────────────────────────────────────────────────────────────
f_nifty_data(_el) =>
    [close > ta.ema(close, _el), ta.rsi(close, 14), (close - close[1]) / close[1] * 100]

[rel_bull,    rel_rsi,    rel_chg]   = request.security("NSE:RELIANCE",   timeframe.period, f_nifty_data(nifty_ema_len))
[hdfcb_bull,  hdfcb_rsi,  hdfcb_chg] = request.security("NSE:HDFCBANK",   timeframe.period, f_nifty_data(nifty_ema_len))
[icicib_bull, icicib_rsi, icicib_chg]= request.security("NSE:ICICIBANK",  timeframe.period, f_nifty_data(nifty_ema_len))
[infy_bull,   infy_rsi,   infy_chg]  = request.security("NSE:INFY",       timeframe.period, f_nifty_data(nifty_ema_len))
[tcs_bull,    tcs_rsi,    tcs_chg]   = request.security("NSE:TCS",        timeframe.period, f_nifty_data(nifty_ema_len))
[lt_bull,     lt_rsi,     lt_chg]    = request.security("NSE:LT",         timeframe.period, f_nifty_data(nifty_ema_len))
[axisb_bull,  axisb_rsi,  axisb_chg] = request.security("NSE:AXISBANK",   timeframe.period, f_nifty_data(nifty_ema_len))
[kotak_bull,  kotak_rsi,  kotak_chg] = request.security("NSE:KOTAKBANK",  timeframe.period, f_nifty_data(nifty_ema_len))
[bharti_bull, bharti_rsi, bharti_chg]= request.security("NSE:BHARTIARTL", timeframe.period, f_nifty_data(nifty_ema_len))
[sbin_bull,   sbin_rsi,   sbin_chg]  = request.security("NSE:SBIN",       timeframe.period, f_nifty_data(nifty_ema_len))
[itc_bull,    itc_rsi,    itc_chg]   = request.security("NSE:ITC",        timeframe.period, f_nifty_data(nifty_ema_len))
[bajfin_bull, bajfin_rsi, bajfin_chg]= request.security("NSE:BAJFINANCE", timeframe.period, f_nifty_data(nifty_ema_len))
[hul_bull,    hul_rsi,    hul_chg]   = request.security("NSE:HINDUNILVR", timeframe.period, f_nifty_data(nifty_ema_len))
[titan_bull,  titan_rsi,  titan_chg] = request.security("NSE:TITAN",      timeframe.period, f_nifty_data(nifty_ema_len))
[maruti_bull, maruti_rsi, maruti_chg]= request.security("NSE:MARUTI",     timeframe.period, f_nifty_data(nifty_ema_len))
[wipro_bull,  wipro_rsi,  wipro_chg] = request.security("NSE:WIPRO",      timeframe.period, f_nifty_data(nifty_ema_len))
[hcl_bull,    hcl_rsi,    hcl_chg]   = request.security("NSE:HCLTECH",    timeframe.period, f_nifty_data(nifty_ema_len))
[ntpc_bull,   ntpc_rsi,   ntpc_chg]  = request.security("NSE:NTPC",       timeframe.period, f_nifty_data(nifty_ema_len))
[ongc_bull,   ongc_rsi,   ongc_chg]  = request.security("NSE:ONGC",       timeframe.period, f_nifty_data(nifty_ema_len))
[power_bull,  power_rsi,  power_chg] = request.security("NSE:POWERGRID",  timeframe.period, f_nifty_data(nifty_ema_len))

nifty_bull_count =
     (rel_bull?1:0)+(hdfcb_bull?1:0)+(icicib_bull?1:0)+(infy_bull?1:0)+(tcs_bull?1:0)+
     (lt_bull?1:0)+(axisb_bull?1:0)+(kotak_bull?1:0)+(bharti_bull?1:0)+(sbin_bull?1:0)+
     (itc_bull?1:0)+(bajfin_bull?1:0)+(hul_bull?1:0)+(titan_bull?1:0)+(maruti_bull?1:0)+
     (wipro_bull?1:0)+(hcl_bull?1:0)+(ntpc_bull?1:0)+(ongc_bull?1:0)+(power_bull?1:0)

nifty_health_pct = math.round(nifty_bull_count / 20 * 100)
nifty_health_str = nifty_health_pct>=70?"STRONG BULL ++":nifty_health_pct>=55?"BULLISH [UP]":nifty_health_pct<=30?"STRONG BEAR --":nifty_health_pct<=45?"BEARISH [DN]":"MIXED [-]"
nifty_health_col = nifty_health_pct>=70?color.new(color.lime,10):nifty_health_pct>=55?color.new(color.green,30):nifty_health_pct<=30?color.new(color.red,10):nifty_health_pct<=45?color.new(color.orange,30):color.new(color.gray,50)

f_draw_nifty_row(_tbl, _row, _name, _bull, _rsi, _chg) =>
    _bg    = _row % 2 == 0 ? color.new(#0d0d1a, 0) : color.new(#111130, 0)
    _chg_s = (_chg >= 0 ? "+" : "") + str.tostring(math.round(_chg, 2)) + "%"
    table.cell(_tbl, 0, _row, _name,                                              text_color=color.white,                    bgcolor=_bg, text_size=nifty_txt_sz, text_halign=text.align_left)
    table.cell(_tbl, 1, _row, _bull?"^ BULL":"v BEAR",                            text_color=_bull?theme_bull:theme_bear,    bgcolor=_bg, text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(_tbl, 2, _row, str.tostring(math.round(_rsi,1)),                   text_color=_rsi>65?theme_bear:_rsi<35?theme_bull:theme_neut, bgcolor=_bg, text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(_tbl, 3, _row, _chg_s,                                             text_color=_chg>=0?theme_bull:theme_bear,  bgcolor=_bg, text_size=nifty_txt_sz, text_halign=text.align_center)

if show_nifty_pulse and barstate.islast
    var table nifty_tbl = table.new(nifty_pos, 4, 23, bgcolor=theme_bg, border_color=theme_border, border_width=1, frame_color=theme_frame, frame_width=2)

    table.cell(nifty_tbl, 0, 0, "[IND] NIFTY PULSE", text_color=color.new(#ffd700,0), bgcolor=theme_head, text_size=nifty_txt_sz, text_halign=text.align_left)
    table.cell(nifty_tbl, 1, 0, "TREND",  text_color=color.white, bgcolor=theme_head, text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(nifty_tbl, 2, 0, "RSI",    text_color=color.white, bgcolor=theme_head, text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(nifty_tbl, 3, 0, "CHG%",   text_color=color.white, bgcolor=theme_head, text_size=nifty_txt_sz, text_halign=text.align_center)

    table.cell(nifty_tbl, 0, 1, "Market Health", text_color=color.new(#ffd700,0), bgcolor=color.new(#0d0d2e,0), text_size=nifty_txt_sz, text_halign=text.align_left)
    table.cell(nifty_tbl, 1, 1, nifty_health_str, text_color=color.white, bgcolor=nifty_health_col,             text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(nifty_tbl, 2, 1, str.tostring(nifty_bull_count)+"/20 Bull", text_color=nifty_bull_count>=12?color.lime:color.red, bgcolor=color.new(#0d0d2e,0), text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(nifty_tbl, 3, 1, str.tostring(nifty_health_pct)+"% [OK]",   text_color=nifty_health_pct>=55?color.lime:color.red, bgcolor=color.new(#0d0d2e,0), text_size=nifty_txt_sz, text_halign=text.align_center)

    table.cell(nifty_tbl, 0, 2, "── STOCK ────", text_color=color.silver, bgcolor=color.new(#111130,0), text_size=nifty_txt_sz, text_halign=text.align_left)
    table.cell(nifty_tbl, 1, 2, "EMA"+str.tostring(nifty_ema_len), text_color=color.silver, bgcolor=color.new(#111130,0), text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(nifty_tbl, 2, 2, "14",   text_color=color.silver, bgcolor=color.new(#111130,0), text_size=nifty_txt_sz, text_halign=text.align_center)
    table.cell(nifty_tbl, 3, 2, "1Bar", text_color=color.silver, bgcolor=color.new(#111130,0), text_size=nifty_txt_sz, text_halign=text.align_center)

    f_draw_nifty_row(nifty_tbl,  3, "RELIANCE",   rel_bull,    rel_rsi,    rel_chg)
    f_draw_nifty_row(nifty_tbl,  4, "HDFCBANK",   hdfcb_bull,  hdfcb_rsi,  hdfcb_chg)
    f_draw_nifty_row(nifty_tbl,  5, "ICICIBANK",  icicib_bull, icicib_rsi, icicib_chg)
    f_draw_nifty_row(nifty_tbl,  6, "INFY",       infy_bull,   infy_rsi,   infy_chg)
    f_draw_nifty_row(nifty_tbl,  7, "TCS",        tcs_bull,    tcs_rsi,    tcs_chg)
    f_draw_nifty_row(nifty_tbl,  8, "LT",         lt_bull,     lt_rsi,     lt_chg)
    f_draw_nifty_row(nifty_tbl,  9, "AXISBANK",   axisb_bull,  axisb_rsi,  axisb_chg)
    f_draw_nifty_row(nifty_tbl, 10, "KOTAKBANK",  kotak_bull,  kotak_rsi,  kotak_chg)
    f_draw_nifty_row(nifty_tbl, 11, "BHARTIARTL", bharti_bull, bharti_rsi, bharti_chg)
    f_draw_nifty_row(nifty_tbl, 12, "SBIN",       sbin_bull,   sbin_rsi,   sbin_chg)
    f_draw_nifty_row(nifty_tbl, 13, "ITC",        itc_bull,    itc_rsi,    itc_chg)
    f_draw_nifty_row(nifty_tbl, 14, "BAJFINANCE", bajfin_bull, bajfin_rsi, bajfin_chg)
    f_draw_nifty_row(nifty_tbl, 15, "HINDUNILVR", hul_bull,    hul_rsi,    hul_chg)
    f_draw_nifty_row(nifty_tbl, 16, "TITAN",      titan_bull,  titan_rsi,  titan_chg)
    f_draw_nifty_row(nifty_tbl, 17, "MARUTI",     maruti_bull, maruti_rsi, maruti_chg)
    f_draw_nifty_row(nifty_tbl, 18, "WIPRO",      wipro_bull,  wipro_rsi,  wipro_chg)
    f_draw_nifty_row(nifty_tbl, 19, "HCLTECH",    hcl_bull,    hcl_rsi,    hcl_chg)
    f_draw_nifty_row(nifty_tbl, 20, "NTPC",       ntpc_bull,   ntpc_rsi,   ntpc_chg)
    f_draw_nifty_row(nifty_tbl, 21, "ONGC",       ongc_bull,   ongc_rsi,   ongc_chg)
    f_draw_nifty_row(nifty_tbl, 22, "POWERGRID",  power_bull,  power_rsi,  power_chg)

// ─────────────────────────────────────────────────────────────
// ══════  WATERMARK / BRAND BADGE  ════════════════════════════
// ─────────────────────────────────────────────────────────────
color c_bg     = color.new(#1a1a2e, 10)
color c_gold   = #ffd700
color c_accent = #00d4ff

var table brand_table = table.new(position.bottom_right, 1, 4, border_width=1, border_color=c_gold, frame_color=c_accent, frame_width=1)
if barstate.islast
    table.cell(brand_table, 0, 0, "ASHISH TRADER",             text_color=c_gold,         text_size=size.large,  text_halign=text.align_center, bgcolor=c_bg)
    table.cell(brand_table, 0, 1, "Sniper V.12.0 Pro Max",     text_color=color.white,    text_size=size.small,  text_halign=text.align_center, bgcolor=c_bg)
    table.cell(brand_table, 0, 2, "+91 9713466747",            text_color=c_accent,       text_size=size.normal, text_halign=text.align_center, bgcolor=c_bg)
    table.cell(brand_table, 0, 3, "Powered by Option Chain AI",text_color=color.new(color.white,50), text_size=size.tiny, text_halign=text.align_center, bgcolor=c_bg)

// ─────────────────────────────────────────────────────────────
// ══════  CONSOLIDATED PREMIUM DASHBOARD  ══════════════════════
// ─────────────────────────────────────────────────────────────
if show_con_dash and barstate.islast
    var table con_dash = table.new(con_pos, 2, 14, bgcolor=theme_bg, border_color=theme_border, border_width=1, frame_color=theme_frame, frame_width=2)

    con_vix_warning = sf_data_ok and not na(vix_close) and (vix_close >= 20.0 or daily_vix_chg >= 5.0)
    con_hdr_txt = con_vix_warning ? "⚠️ CRITICAL VOLATILITY ⚠️" : "★ SNIPER CONSOLIDATED V.12.0 PRO ★"
    table.cell(con_dash, 0, 0, con_hdr_txt, text_color=con_vix_warning?color.red:color.yellow, bgcolor=theme_head, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 0, "STATUS / INFO", text_color=color.white, bgcolor=theme_head, text_size=con_txt_sz, text_halign=text.align_center)

    table.cell(con_dash, 0, 1, "─── OI & Option Chain ───", text_color=color.yellow, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 1, "", bgcolor=theme_bg, text_size=con_txt_sz)

    table.cell(con_dash, 0, 2, "OI Buildup Phase",        text_color=color.gray,         bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 2, oi_buildup_str,             text_color=oi_buildup_col,     bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_center)
    table.cell(con_dash, 0, 3, "Synthetic PCR",            text_color=color.gray,         bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 3, show_syn_pcr?syn_pcr_str:"OFF",     text_color=show_syn_pcr?syn_pcr_col:color.gray,    bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_center)
    table.cell(con_dash, 0, 4, "Option Writer Sentiment",  text_color=color.gray,         bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 4, show_syn_pcr?writer_sent_str:"OFF", text_color=show_syn_pcr?writer_sent_col:color.gray, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_center)
    table.cell(con_dash, 0, 5, "CPR Classification",       text_color=color.yellow,       bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 5, show_cpr_dash?cpr_class_str:"DISABLED", text_color=show_cpr_dash?color.black:color.gray, bgcolor=show_cpr_dash?cpr_class_col:theme_bg, text_size=con_txt_sz, text_halign=text.align_center)

    table.cell(con_dash, 0, 6, "─── Nifty Market Health ───", text_color=color.white, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 6, "", bgcolor=theme_bg, text_size=con_txt_sz)

    table.cell(con_dash, 0, 7, "Pulse Health",      text_color=color.gray, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 7, nifty_health_str,    text_color=color.white, bgcolor=nifty_health_col, text_size=con_txt_sz, text_halign=text.align_center)
    table.cell(con_dash, 0, 8, "Nifty Pulse State", text_color=color.gray, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 8, str.tostring(nifty_bull_count)+"/20 Bull (" + str.tostring(nifty_health_pct) + "%)", text_color=nifty_bull_count>=12?color.lime:color.red, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_center)

    table.cell(con_dash, 0, 9, "─── Market Snapshot ───", text_color=color.white, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 9, "", bgcolor=theme_bg, text_size=con_txt_sz)

    con_s_bg  = status_str=="BUY"?color.new(color.lime,20):status_str=="SELL"?color.new(color.red,20):status_str=="ADX WEAK"?color.new(color.orange,20):color.new(color.gray,50)
    con_s_txt = status_str=="BUY"?color.black:color.white
    table.cell(con_dash, 0, 10, "Signal Status",     text_color=color.gray, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 10, status_str,           text_color=con_s_txt, bgcolor=con_s_bg, text_size=con_txt_sz, text_halign=text.align_center)
    table.cell(con_dash, 0, 11, "Signal Confidence", text_color=color.gray, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 11, last_conf_str,        text_color=last_conf_col, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_center)

    con_b_bg = market_bias=="STRONG BULL"?color.new(color.green,20):market_bias=="BULL"?color.new(color.lime,40):market_bias=="STRONG BEAR"?color.new(color.red,20):market_bias=="BEAR"?color.new(color.orange,40):color.new(color.gray,20)
    table.cell(con_dash, 0, 12, "Market Bias",       text_color=color.gray, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 12, market_bias,          text_color=color.white, bgcolor=con_b_bg, text_size=con_txt_sz, text_halign=text.align_center)

    con_sc_bg  = bull_pct>=75?color.new(color.green,20):bull_pct>=55?color.new(color.lime,40):bull_pct<=25?color.new(color.red,20):bull_pct<=45?color.new(color.orange,30):color.new(color.gray,40)
    con_sc_txt = (bull_pct>=55 and bull_pct<75) or (bull_pct>25 and bull_pct<=45) ? color.black : color.white
    table.cell(con_dash, 0, 13, "Bull / Bear Score", text_color=color.gray, bgcolor=theme_bg, text_size=con_txt_sz, text_halign=text.align_left)
    table.cell(con_dash, 1, 13, str.tostring(bull_pct)+"% Bull | "+str.tostring(bear_pct)+"% Bear", text_color=con_sc_txt, bgcolor=con_sc_bg, text_size=con_txt_sz, text_halign=text.align_center)

// ─────────────────────────────────────────────────────────────
// ══════  ALERTS  ═════════════════════════════════════════════
// ─────────────────────────────────────────────────────────────
alertcondition(final_buy,  "ðŸŸĒ Sniper BUY",  "Sniper BUY on {{ticker}} @ {{close}}")
alertcondition(final_sell, "ðŸ”ī Sniper SELL", "Sniper SELL on {{ticker}} @ {{close}}")

alertcondition(final_buy  and oi_chg > 0, "ðŸ”Ĩ High Conviction OI BUY (Long Buildup)",   "HC-BUY on {{ticker}} @ {{close}} — Long Buildup")
alertcondition(final_sell and oi_chg > 0, "ðŸ”Ĩ High Conviction OI SELL (Short Buildup)",  "HC-SELL on {{ticker}} @ {{close}} — Short Buildup")

alertcondition(is_bull_trap, "ðŸŠĪ Bull Trap Alert",   "Bull Trap / Fake Breakout on {{ticker}}")
alertcondition(is_bear_trap, "ðŸŠĪ Bear Trap Alert",   "Bear Trap / Fake Breakdown on {{ticker}}")
alertcondition(wtt_shift,    "↗️ WTT Shift Alert",   "Weak Towards Top Shift on {{ticker}}")
alertcondition(wtb_shift,    "↘️ WTB Shift Alert",   "Weak Towards Bottom Shift on {{ticker}}")

alertcondition(bull_pin_sup, "ðŸ”Ļ Bullish Pin Bar @ Support",    "Bullish Pin Bar Rejection at Support on {{ticker}} @ {{close}}")
alertcondition(bear_pin_res, "⭐ Bearish Pin Bar @ Resistance", "Bearish Pin Bar Rejection at Resistance on {{ticker}} @ {{close}}")

💎 Comments

Share your thoughts:

Post a Comment
Smart Chat
Hi — welcome to Ashish Trader! 😊
I'm here to help with indicators, EAs, strategies, or community access — tell me what you need. 🔧 Would you like guidance on a specific tool, pricing for premium indicators, or joining our Telegram/YouTube community? ðŸ“Ģ