ElevateOne MasterFilter V1.0

steven_martinezjr00 · study · 1291 行 · 点赞 9 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("ElevateOne MasterFilter V1.0", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=100)
 
// ======================================================
// ELEVATEONE MASTERFILTER V1.0
// COMPLETE ORB + ORR DUAL SIGNAL INDICATOR
//
// ORB: ALL CONFIRMED CLOSING BREAKOUTS / RE-BREAKOUTS
// ORR: OPENING RANGE SWEEP + REJECTION
//
// SHARED OPENING RANGE: 9:30 - 9:45 AM NEW YORK
// 50% MIDPOINT: WHITE DASHED LINE
//
// DESIGNED FOR NQ / MNQ 3M AND 5M
// ======================================================
 
string TZ = "America/New_York"
 
// ===================== SETTINGS =======================
 
string gMain = "01 | Master Settings"
 
bool enableORB = input.bool(true, "Enable ORB", group=gMain)
bool enableORR = input.bool(true, "Enable ORR", group=gMain)
 
int maxDaily = input.int(
     2, "Maximum Daily Modeled Entries",
     minval=1, maxval=5, group=gMain)
 
int cooldownBars = input.int(
     3, "Entry Cooldown Bars",
     minval=0, maxval=20, group=gMain)
 
bool onePerDirection = input.bool(
     true, "One Entry Per Direction Daily",
     group=gMain)
 
string gORB = "02 | ORB Sniper Filters"
 
float breakoutPct = input.float(
     0.15, "Sniper Minimum Breakout %",
     minval=0.01, step=0.01, group=gORB)
 
float volumeMult = input.float(
     1.5, "Relative Volume Minimum",
     minval=0.5, step=0.1, group=gORB)
 
int volumeLength = input.int(
     20, "Volume Average Length",
     minval=5, group=gORB)
 
float orbBodyMin = input.float(
     60.0, "Minimum Candle Body %",
     minval=10, maxval=100, group=gORB)
 
float orbStopBuffer = input.float(
     5.0, "ORB Stop Buffer (Points)",
     minval=0, step=0.25, group=gORB)
 
float orbTP1R = input.float(
     1.5, "ORB TP1 (R)",
     minval=0.5, group=gORB)
 
float orbTP2R = input.float(
     2.5, "ORB TP2 (R)",
     minval=1.0, group=gORB)
 
string gORR = "03 | ORR Sniper Filters"
 
float wickMin = input.float(
     50.0, "Minimum Rejection Wick %",
     minval=10, maxval=90, group=gORR)
 
float orrStopBuffer = input.float(
     5.0, "ORR Stop Buffer (Points)",
     minval=0, step=0.25, group=gORR)
 
float orrMinRR = input.float(
     1.5, "Minimum VWAP Reward/Risk",
     minval=0.5, step=0.25, group=gORR)
 
int maxSweepBars = input.int(
     2, "Maximum Bars After Sweep",
     minval=0, maxval=5, group=gORR)
 
float minInsidePct = input.float(
     10.0, "Minimum Reentry Depth %",
     minval=0, maxval=50, group=gORR)
 
string gVisual = "04 | Chart Display"
 
bool showAllSetups = input.bool(
     true, "Show All Confirmed ORB / ORR Signals",
     group=gVisual)
 
bool showSniper = input.bool(
     true, "Show Sniper-Qualified Signals",
     group=gVisual)
 
bool showEntries = input.bool(
     true, "Show Modeled Entry Markers",
     group=gVisual)
 
bool showEMA = input.bool(
     true, "Show EMA 9 / EMA 20",
     group=gVisual)
 
bool showCrossDots = input.bool(
     true, "Show EMA Crossover Dots",
     group=gVisual)
 
bool showVWAP = input.bool(
     true, "Show VWAP",
     group=gVisual)
 
bool showRange = input.bool(
     true, "Show Opening Range High / Low",
     group=gVisual)
 
bool showMidpoint = input.bool(
     true, "Show 50% OR Midpoint",
     group=gVisual)
 
bool showBox = input.bool(
     true, "Show Opening Range Box",
     group=gVisual)
 
bool showTradeLevels = input.bool(
     true, "Show Entry / Stop / Targets",
     group=gVisual)
 
bool showDashboard = input.bool(
     true, "Show Dashboard",
     group=gVisual)
 
// ====================== TIME ==========================
 
int yy = year(time, TZ)
int mm = month(time, TZ)
int dd = dayofmonth(time, TZ)
 
int dayID = yy * 10000 + mm * 100 + dd
bool newDay = na(dayID[1]) or dayID != dayID[1]
 
int sessionOpen = timestamp(TZ, yy, mm, dd, 9, 30)
int rangeEnd = timestamp(TZ, yy, mm, dd, 9, 45)
int entryStart = timestamp(TZ, yy, mm, dd, 10, 0)
int entryCutoff = timestamp(TZ, yy, mm, dd, 11, 30)
int sessionEnd = timestamp(TZ, yy, mm, dd, 16, 0)
 
bool validTF = timeframe.isminutes and (
     timeframe.multiplier == 3 or
     timeframe.multiplier == 5)
 
bool inRange = (
     time >= sessionOpen and
     time < rangeEnd)
 
bool inSession = (
     time >= sessionOpen and
     time < sessionEnd)
 
bool afterRange = (
     time >= rangeEnd and
     time < sessionEnd)
 
bool sniperWindow = (
     time >= entryStart and
     time_close <= entryCutoff)
 
bool entryWindow = (
     time >= entryStart and
     time < entryCutoff)
 
// ==================== INDICATORS ======================
 
float ema9 = ta.ema(close, 9)
float ema20 = ta.ema(close, 20)
float vwapValue = ta.vwap(hlc3)
 
float avgVolume = ta.sma(
     volume, volumeLength)[1]
 
bool highVolume = (
     not na(avgVolume) and
     volume >= avgVolume * volumeMult)
 
bool emaBull = (
     ema9 > ema20 and close > ema9)
 
bool emaBear = (
     ema9 < ema20 and close < ema9)
 
bool crossUp = (
     ta.crossover(ema9, ema20) and
     barstate.isconfirmed)
 
bool crossDown = (
     ta.crossunder(ema9, ema20) and
     barstate.isconfirmed)
 
plot(
     showEMA ? ema9 : na,
     "EMA 9",
     color=color.yellow,
     linewidth=2)
 
plot(
     showEMA ? ema20 : na,
     "EMA 20",
     color=color.blue,
     linewidth=2)
 
plot(
     showVWAP ? vwapValue : na,
     "VWAP",
     color=color.orange,
     linewidth=2)
 
plot(
     showCrossDots and crossUp ? ema9 : na,
     "Bullish EMA Crossover",
     color=color.lime,
     linewidth=5,
     style=plot.style_circles)
 
plot(
     showCrossDots and crossDown ? ema9 : na,
     "Bearish EMA Crossover",
     color=color.red,
     linewidth=5,
     style=plot.style_circles)
 
// ==================== STATE ===========================
 
var float orHigh = na
var float orLow = na
 
var box rangeBox = na
var line midpointLine = na
 
var int tradesToday = 0
var bool longUsed = false
var bool shortUsed = false
var int lastEntryBar = na
 
// Pending modeled entry
// 1 = ORB, 2 = ORR
 
var int pendingStrategy = 0
var int pendingDir = 0
var int pendingBar = na
 
var float pendingExtreme = na
var float pendingVWAP = na
 
// Active modeled trade
 
var bool active = false
var int activeStrategy = 0
var int activeDir = 0
var int activeEntryBar = na
 
var float entry = na
var float stop = na
var float tp1 = na
var float tp2 = na
 
var bool hitTP1 = false
 
// Sweep tracking
 
var int highSweepBar = na
var int lowSweepBar = na
 
var float highSweepExtreme = na
var float lowSweepExtreme = na
 
// Trade drawings
 
var line entryLine = na
var line stopLine = na
var line tp1Line = na
var line tp2Line = na
 
// ==================== DAILY RESET ====================
 
if newDay
    orHigh := na
    orLow := na
 
    rangeBox := na
    midpointLine := na
 
    tradesToday := 0
    longUsed := false
    shortUsed := false
    lastEntryBar := na
 
    pendingStrategy := 0
    pendingDir := 0
    pendingBar := na
    pendingExtreme := na
    pendingVWAP := na
 
    active := false
    activeStrategy := 0
    activeDir := 0
    activeEntryBar := na
 
    entry := na
    stop := na
    tp1 := na
    tp2 := na
    hitTP1 := false
 
    highSweepBar := na
    lowSweepBar := na
    highSweepExtreme := na
    lowSweepExtreme := na
 
    if not na(entryLine)
        line.set_extend(entryLine, extend.none)
        line.set_x2(entryLine, bar_index - 1)
 
    if not na(stopLine)
        line.set_extend(stopLine, extend.none)
        line.set_x2(stopLine, bar_index - 1)
 
    if not na(tp1Line)
        line.set_extend(tp1Line, extend.none)
        line.set_x2(tp1Line, bar_index - 1)
 
    if not na(tp2Line)
        line.set_extend(tp2Line, extend.none)
        line.set_x2(tp2Line, bar_index - 1)
 
    entryLine := na
    stopLine := na
    tp1Line := na
    tp2Line := na
 
// ==================== OPENING RANGE ===================
 
// Both ORB and ORR use this SAME 15M range.
 
if inRange
    orHigh := na(orHigh) ?
         high : math.max(orHigh, high)
 
    orLow := na(orLow) ?
         low : math.min(orLow, low)
 
    if showBox
        if na(rangeBox)
            rangeBox := box.new(
                 bar_index,
                 orHigh,
                 bar_index,
                 orLow,
                 bgcolor=color.new(color.teal, 90),
                 border_color=color.teal)
        else
            box.set_right(rangeBox, bar_index)
            box.set_top(rangeBox, orHigh)
            box.set_bottom(rangeBox, orLow)
 
bool rangeReady = (
     afterRange and
     not na(orHigh) and
     not na(orLow) and
     orHigh > orLow)
 
float orWidth = rangeReady ?
     orHigh - orLow : na
 
// ==================== 50% MIDPOINT ====================
 
float orMidpoint = (
     not na(orHigh) and
     not na(orLow)) ?
     (orHigh + orLow) / 2.0 : na
 
plot(
     showRange and inSession ? orHigh : na,
     "15M OR HIGH (100%)",
     color=color.lime,
     linewidth=2,
     style=plot.style_linebr)
 
plot(
     showRange and inSession ? orLow : na,
     "15M OR LOW (0%)",
     color=color.red,
     linewidth=2,
     style=plot.style_linebr)
 
// Dashed white midpoint line, created once
// the 15-minute opening range is complete.
 
if rangeReady and showMidpoint
    if na(midpointLine)
        midpointLine := line.new(
             bar_index,
             orMidpoint,
             bar_index + 1,
             orMidpoint,
             color=color.white,
             width=2,
             style=line.style_dashed,
             extend=extend.right)
 
    else
        line.set_y1(midpointLine, orMidpoint)
        line.set_y2(midpointLine, orMidpoint)
 
if not na(midpointLine) and time >= sessionEnd
    line.set_extend(midpointLine, extend.none)
    line.set_x2(midpointLine, bar_index)
 
// ==================== CANDLE STRENGTH =================
 
float candleRange = math.max(
     high - low, syminfo.mintick)
 
float bodyPct = (
     math.abs(close - open) /
     candleRange * 100)
 
float upperWickPct = (
     high - math.max(open, close)) /
     candleRange * 100
 
float lowerWickPct = (
     math.min(open, close) - low) /
     candleRange * 100
 
// ==================== SWEEP TRACKING ==================
 
// A sweep is a break beyond an OR boundary.
// Reversal confirmation can happen within
// the configured number of bars.
 
if rangeReady and barstate.isconfirmed
 
    if not na(highSweepBar) and (
         bar_index - highSweepBar > maxSweepBars)
        highSweepBar := na
        highSweepExtreme := na
 
    if not na(lowSweepBar) and (
         bar_index - lowSweepBar > maxSweepBars)
        lowSweepBar := na
        lowSweepExtreme := na
 
    if high > orHigh
        if na(highSweepBar)
            highSweepBar := bar_index
            highSweepExtreme := high
        else
            highSweepExtreme := math.max(
                 highSweepExtreme, high)
 
    if low < orLow
        if na(lowSweepBar)
            lowSweepBar := bar_index
            lowSweepExtreme := low
        else
            lowSweepExtreme := math.min(
                 lowSweepExtreme, low)
 
bool freshHighSweep = (
     not na(highSweepBar) and
     bar_index - highSweepBar <= maxSweepBars)
 
bool freshLowSweep = (
     not na(lowSweepBar) and
     bar_index - lowSweepBar <= maxSweepBars)
 
// ==================== ALL ORB BREAKOUTS ===============
 
// IMPORTANT:
// Raw ORB signals have NO volume, EMA, VWAP,
// candle-strength, or Sniper time restrictions.
//
// Every new confirmed CLOSE crossing outside
// the opening range generates a breakout signal.
//
// A candle that remains outside the range
// without crossing again is NOT a new breakout.
 
bool crossedUp = ta.crossover(close, orHigh)
bool crossedDown = ta.crossunder(close, orLow)
 
bool rawORBLong = (
     enableORB and
     validTF and
     barstate.isconfirmed and
     rangeReady and
     crossedUp)
 
bool rawORBShort = (
     enableORB and
     validTF and
     barstate.isconfirmed and
     rangeReady and
     crossedDown)
 
// Extra breakout distance is required ONLY
// for the ORB Sniper classification.
 
float upperBreakLevel = rangeReady ?
     orHigh * (1 + breakoutPct / 100) : na
 
float lowerBreakLevel = rangeReady ?
     orLow * (1 - breakoutPct / 100) : na
 
// ==================== ALL ORR REVERSALS ===============
 
// Raw ORR = recent liquidity sweep followed
// by a confirmed candle closing back inside OR.
 
bool rawORRLong = (
     enableORR and
     validTF and
     barstate.isconfirmed and
     rangeReady and
     freshLowSweep and
     close > orLow and
     close < orHigh and
     close > open)
 
bool rawORRShort = (
     enableORR and
     validTF and
     barstate.isconfirmed and
     rangeReady and
     freshHighSweep and
     close < orHigh and
     close > orLow and
     close < open)
 
// ==================== SNIPER FILTERS ==================
 
bool strongBull = (
     close > open and
     bodyPct >= orbBodyMin)
 
bool strongBear = (
     close < open and
     bodyPct >= orbBodyMin)
 
bool sniperORBLong = (
     rawORBLong and
     sniperWindow and
     close >= upperBreakLevel and
     highVolume and
     strongBull and
     emaBull and
     close > vwapValue)
 
bool sniperORBShort = (
     rawORBShort and
     sniperWindow and
     close <= lowerBreakLevel and
     highVolume and
     strongBear and
     emaBear and
     close < vwapValue)
 
float insideDepth = rangeReady ?
     orWidth * minInsidePct / 100 : na
 
bool longInside = (
     rangeReady and
     close > orLow + insideDepth and
     close < orHigh)
 
bool shortInside = (
     rangeReady and
     close < orHigh - insideDepth and
     close > orLow)
 
bool longRejection = (
     lowerWickPct >= wickMin and
     longInside)
 
bool shortRejection = (
     upperWickPct >= wickMin and
     shortInside)
 
float longORRStop = (
     lowSweepExtreme - orrStopBuffer)
 
float shortORRStop = (
     highSweepExtreme + orrStopBuffer)
 
float longRisk = close - longORRStop
float shortRisk = shortORRStop - close
 
float longVWAPReward = vwapValue - close
float shortVWAPReward = close - vwapValue
 
bool longRRValid = (
     longRisk > syminfo.mintick and
     longVWAPReward >= longRisk * orrMinRR and
     orHigh > vwapValue)
 
bool shortRRValid = (
     shortRisk > syminfo.mintick and
     shortVWAPReward >= shortRisk * orrMinRR and
     orLow < vwapValue)
 
bool sniperORRLong = (
     rawORRLong and
     sniperWindow and
     longRejection and
     longRRValid)
 
bool sniperORRShort = (
     rawORRShort and
     sniperWindow and
     shortRejection and
     shortRRValid)
 
// ==================== RAW SIGNAL MARKERS ==============
 
// Teal = ORB
// Purple = ORR
//
// These remain visible regardless of active
// trades, daily limits, or Sniper qualification.
 
plotshape(
     showAllSetups and rawORBLong,
     title="ORB BUY Confirmed",
     text="ORB BUY",
     style=shape.labelup,
     location=location.belowbar,
     color=color.new(color.teal, 35),
     textcolor=color.white,
     size=size.tiny)
 
plotshape(
     showAllSetups and rawORBShort,
     title="ORB SELL Confirmed",
     text="ORB SELL",
     style=shape.labeldown,
     location=location.abovebar,
     color=color.new(color.teal, 35),
     textcolor=color.white,
     size=size.tiny)
 
plotshape(
     showAllSetups and rawORRLong,
     title="ORR BUY Confirmed",
     text="ORR BUY",
     style=shape.labelup,
     location=location.belowbar,
     color=color.new(color.purple, 35),
     textcolor=color.white,
     size=size.tiny)
 
plotshape(
     showAllSetups and rawORRShort,
     title="ORR SELL Confirmed",
     text="ORR SELL",
     style=shape.labeldown,
     location=location.abovebar,
     color=color.new(color.purple, 35),
     textcolor=color.white,
     size=size.tiny)
 
// ==================== SNIPER MARKERS ===================
 
// Diamonds identify strategy-qualified setups.
// A Sniper marker does not guarantee an entry.
 
plotshape(
     showSniper and sniperORBLong,
     title="ORB Sniper BUY",
     text="ORB S",
     style=shape.diamond,
     location=location.belowbar,
     color=color.lime,
     textcolor=color.white,
     size=size.small)
 
plotshape(
     showSniper and sniperORBShort,
     title="ORB Sniper SELL",
     text="ORB S",
     style=shape.diamond,
     location=location.abovebar,
     color=color.red,
     textcolor=color.white,
     size=size.small)
 
plotshape(
     showSniper and sniperORRLong,
     title="ORR Sniper BUY",
     text="ORR S",
     style=shape.diamond,
     location=location.belowbar,
     color=color.aqua,
     textcolor=color.white,
     size=size.small)
 
plotshape(
     showSniper and sniperORRShort,
     title="ORR Sniper SELL",
     text="ORR S",
     style=shape.diamond,
     location=location.abovebar,
     color=color.fuchsia,
     textcolor=color.white,
     size=size.small)
 
// ==================== ENTRY RESTRICTIONS ==============
 
// All raw and Sniper signals remain visible.
// Only modeled entries obey these restrictions.
 
bool cooldownOK = (
     na(lastEntryBar) or
     bar_index - lastEntryBar > cooldownBars)
 
bool canEnter = (
     not active and
     pendingStrategy == 0 and
     tradesToday < maxDaily and
     cooldownOK)
 
bool allowLong = (
     not onePerDirection or not longUsed)
 
bool allowShort = (
     not onePerDirection or not shortUsed)
 
// Deterministic entry priority:
// ORB long, ORB short, ORR long, ORR short.
 
bool takeORBLong = (
     sniperORBLong and
     canEnter and allowLong)
 
bool takeORBShort = (
     sniperORBShort and
     canEnter and allowShort and
     not takeORBLong)
 
bool takeORRLong = (
     sniperORRLong and
     canEnter and allowLong and
     not takeORBLong and
     not takeORBShort)
 
bool takeORRShort = (
     sniperORRShort and
     canEnter and allowShort and
     not takeORBLong and
     not takeORBShort and
     not takeORRLong)
 
// ==================== QUEUE MODELED ENTRY =============
 
if takeORBLong or takeORBShort
    pendingStrategy := 1
    pendingDir := takeORBLong ? 1 : -1
    pendingBar := bar_index
    pendingExtreme := na
    pendingVWAP := na
 
else if takeORRLong or takeORRShort
    pendingStrategy := 2
    pendingDir := takeORRLong ? 1 : -1
    pendingBar := bar_index
 
    pendingExtreme := takeORRLong ?
         lowSweepExtreme : highSweepExtreme
 
    pendingVWAP := vwapValue
 
// ==================== NEXT-BAR ENTRY ==================
 
bool enteredORBLong = false
bool enteredORBShort = false
bool enteredORRLong = false
bool enteredORRShort = false
 
if pendingStrategy != 0 and (
     bar_index > pendingBar)
 
    float proposedEntry = open
    float proposedStop = na
    float proposedTP1 = na
    float proposedTP2 = na
 
    bool validTrade = (
         entryWindow and
         tradesToday < maxDaily and
         not active)
 
    if pendingStrategy == 1
 
        proposedStop := pendingDir == 1 ?
             orHigh - orbStopBuffer :
             orLow + orbStopBuffer
 
        float risk = (
             proposedEntry - proposedStop) *
             pendingDir
 
        validTrade := (
             validTrade and
             risk > syminfo.mintick)
 
        if validTrade
            proposedTP1 := (
                 proposedEntry +
                 pendingDir * risk * orbTP1R)
 
            proposedTP2 := (
                 proposedEntry +
                 pendingDir * risk * orbTP2R)
 
    else
 
        proposedStop := pendingDir == 1 ?
             pendingExtreme - orrStopBuffer :
             pendingExtreme + orrStopBuffer
 
        proposedTP1 := pendingVWAP
 
        proposedTP2 := pendingDir == 1 ?
             orHigh : orLow
 
        float risk = (
             proposedEntry - proposedStop) *
             pendingDir
 
        float reward1 = (
             proposedTP1 - proposedEntry) *
             pendingDir
 
        float reward2 = (
             proposedTP2 - proposedTP1) *
             pendingDir
 
        validTrade := (
             validTrade and
             risk > syminfo.mintick and
             reward1 >= risk * orrMinRR and
             reward2 > syminfo.mintick)
 
    if validTrade
 
        active := true
        activeStrategy := pendingStrategy
        activeDir := pendingDir
        activeEntryBar := bar_index
 
        entry := proposedEntry
        stop := proposedStop
        tp1 := proposedTP1
        tp2 := proposedTP2
 
        hitTP1 := false
 
        tradesToday += 1
        lastEntryBar := bar_index
 
        if activeDir == 1
            longUsed := true
        else
            shortUsed := true
 
        enteredORBLong := (
             activeStrategy == 1 and
             activeDir == 1)
 
        enteredORBShort := (
             activeStrategy == 1 and
             activeDir == -1)
 
        enteredORRLong := (
             activeStrategy == 2 and
             activeDir == 1)
 
        enteredORRShort := (
             activeStrategy == 2 and
             activeDir == -1)
 
        if showTradeLevels
 
            color levelColor = (
                 activeStrategy == 1 ?
                 color.teal : color.purple)
 
            entryLine := line.new(
                 bar_index, entry,
                 bar_index + 1, entry,
                 extend=extend.right,
                 color=levelColor,
                 width=2)
 
            stopLine := line.new(
                 bar_index, stop,
                 bar_index + 1, stop,
                 extend=extend.right,
                 color=color.red,
                 width=2)
 
            tp1Line := line.new(
                 bar_index, tp1,
                 bar_index + 1, tp1,
                 extend=extend.right,
                 color=color.orange,
                 width=2)
 
            tp2Line := line.new(
                 bar_index, tp2,
                 bar_index + 1, tp2,
                 extend=extend.right,
                 color=color.lime,
                 width=2)
 
    pendingStrategy := 0
    pendingDir := 0
    pendingBar := na
 
    pendingExtreme := na
    pendingVWAP := na
 
// ==================== TRADE MANAGEMENT ================
 
// Approximate OHLC-based trade management.
// Not a TradingView strategy/backtest.
//
// Entry bar is excluded from stop/target checks.
// When stop and target are touched on the same
// subsequent bar, stop receives priority.
 
bool tp1Event = false
bool tp2Event = false
bool stopEvent = false
bool sessionExit = false
 
if active and barstate.isconfirmed and (
     bar_index > activeEntryBar)
 
    bool stopTouched = activeDir == 1 ?
         low <= stop : high >= stop
 
    bool tp1Touched = activeDir == 1 ?
         high >= tp1 : low <= tp1
 
    bool tp2Touched = activeDir == 1 ?
         high >= tp2 : low <= tp2
 
    if stopTouched
        stopEvent := true
        active := false
 
    else
        if not hitTP1 and tp1Touched
            hitTP1 := true
            tp1Event := true
 
            stop := entry
 
            if not na(stopLine)
                line.set_y1(stopLine, stop)
                line.set_y2(stopLine, stop)
 
        if tp2Touched
            tp2Event := true
            active := false
 
if active and time_close >= sessionEnd
    sessionExit := true
    active := false
 
if stopEvent or tp2Event or sessionExit
 
    if not na(entryLine)
        line.set_extend(entryLine, extend.none)
        line.set_x2(entryLine, bar_index)
 
    if not na(stopLine)
        line.set_extend(stopLine, extend.none)
        line.set_x2(stopLine, bar_index)
 
    if not na(tp1Line)
        line.set_extend(tp1Line, extend.none)
        line.set_x2(tp1Line, bar_index)
 
    if not na(tp2Line)
        line.set_extend(tp2Line, extend.none)
        line.set_x2(tp2Line, bar_index)
 
// ==================== ENTRY MARKERS ===================
 
plotshape(
     showEntries and enteredORBLong,
     title="ORB Long Entry",
     text="ORB ENTRY",
     style=shape.triangleup,
     location=location.belowbar,
     color=color.lime,
     textcolor=color.white,
     size=size.small)
 
plotshape(
     showEntries and enteredORBShort,
     title="ORB Short Entry",
     text="ORB ENTRY",
     style=shape.triangledown,
     location=location.abovebar,
     color=color.red,
     textcolor=color.white,
     size=size.small)
 
plotshape(
     showEntries and enteredORRLong,
     title="ORR Long Entry",
     text="ORR ENTRY",
     style=shape.triangleup,
     location=location.belowbar,
     color=color.aqua,
     textcolor=color.white,
     size=size.small)
 
plotshape(
     showEntries and enteredORRShort,
     title="ORR Short Entry",
     text="ORR ENTRY",
     style=shape.triangledown,
     location=location.abovebar,
     color=color.fuchsia,
     textcolor=color.white,
     size=size.small)
 
plotshape(
     tp1Event,
     title="TP1 Reached",
     style=shape.circle,
     location=location.abovebar,
     color=color.orange,
     size=size.tiny)
 
plotshape(
     tp2Event,
     title="TP2 Reached",
     style=shape.circle,
     location=location.abovebar,
     color=color.lime,
     size=size.tiny)
 
plotshape(
     stopEvent,
     title="Stop Reached",
     style=shape.xcross,
     location=location.abovebar,
     color=color.red,
     size=size.tiny)
 
// ==================== DASHBOARD =======================
 
var table dash = table.new(
     position.top_right, 2, 10,
     border_width=1)
 
if barstate.islast
 
    if showDashboard
 
        color bg = color.rgb(25, 27, 35)
 
        table.cell(
             dash, 0, 0, "ELEVATEONE",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 0, "MASTERFILTER V1.0",
             text_color=color.lime,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 1, "TIMEFRAME",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 1,
             validTF ? "VALID" : "USE 3M / 5M",
             text_color=validTF ?
             color.lime : color.orange,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 2, "15M RANGE",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 2,
             rangeReady ? "READY" : "WAITING",
             text_color=rangeReady ?
             color.lime : color.orange,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 3, "EMA TREND",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 3,
             ema9 > ema20 ? "BULLISH" : "BEARISH",
             text_color=ema9 > ema20 ?
             color.lime : color.red,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 4, "VWAP",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 4,
             close > vwapValue ? "ABOVE" : "BELOW",
             text_color=close > vwapValue ?
             color.lime : color.red,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 5, "ORB",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 5,
             enableORB ? "ON" : "OFF",
             text_color=enableORB ?
             color.lime : color.gray,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 6, "ORR",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 6,
             enableORR ? "ON" : "OFF",
             text_color=enableORR ?
             color.lime : color.gray,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 7, "DAILY ENTRIES",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 7,
             str.tostring(tradesToday) +
             " / " + str.tostring(maxDaily),
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 8, "SIGNALS",
             text_color=color.white,
             bgcolor=bg)
 
        table.cell(
             dash, 1, 8,
             showAllSetups ?
             "ALL + SNIPER" : "SNIPER ONLY",
             text_color=color.aqua,
             bgcolor=bg)
 
        table.cell(
             dash, 0, 9, "TRADE STATUS",
             text_color=color.white,
             bgcolor=bg)
 
        string status = active ?
             (activeStrategy == 1 ?
             "ORB ACTIVE" : "ORR ACTIVE") :
             pendingStrategy != 0 ?
             "PENDING" : "WAITING"
 
        table.cell(
             dash, 1, 9, status,
             text_color=active ?
             color.lime : color.white,
             bgcolor=bg)
 
    else
        table.clear(dash, 0, 0, 1, 9)
 
// ==================== ALERTS ==========================
 
// Every confirmed ORB breakout
alertcondition(
     rawORBLong,
     "ORB BUY Confirmed",
     "ElevateOne: ORB BUY confirmed on {{ticker}}")
 
alertcondition(
     rawORBShort,
     "ORB SELL Confirmed",
     "ElevateOne: ORB SELL confirmed on {{ticker}}")
 
// Every confirmed ORR reversal
alertcondition(
     rawORRLong,
     "ORR BUY Confirmed",
     "ElevateOne: ORR BUY confirmed on {{ticker}}")
 
alertcondition(
     rawORRShort,
     "ORR SELL Confirmed",
     "ElevateOne: ORR SELL confirmed on {{ticker}}")
 
// Sniper qualification
alertcondition(
     sniperORBLong,
     "ORB Sniper BUY",
     "ElevateOne: ORB Sniper BUY on {{ticker}}")
 
alertcondition(
     sniperORBShort,
     "ORB Sniper SELL",
     "ElevateOne: ORB Sniper SELL on {{ticker}}")
 
alertcondition(
     sniperORRLong,
     "ORR Sniper BUY",
     "ElevateOne: ORR Sniper BUY on {{ticker}}")
 
alertcondition(
     sniperORRShort,
     "ORR Sniper SELL",
     "ElevateOne: ORR Sniper SELL on {{ticker}}")
 
// Modeled entries
alertcondition(
     enteredORBLong,
     "ORB Long Entry",
     "ElevateOne: Modeled ORB LONG entry on {{ticker}}")
 
alertcondition(
     enteredORBShort,
     "ORB Short Entry",
     "ElevateOne: Modeled ORB SHORT entry on {{ticker}}")
 
alertcondition(
     enteredORRLong,
     "ORR Long Entry",
     "ElevateOne: Modeled ORR LONG entry on {{ticker}}")
 
alertcondition(
     enteredORRShort,
     "ORR Short Entry",
     "ElevateOne: Modeled ORR SHORT entry on {{ticker}}")
 
// Trade management
alertcondition(
     tp1Event,
     "TP1 Reached",
     "ElevateOne: TP1 reached on {{ticker}}")
 
alertcondition(
     tp2Event,
     "TP2 Reached",
     "ElevateOne: TP2 reached on {{ticker}}")
 
alertcondition(
     stopEvent,
     "Stop Reached",
     "ElevateOne: Stop touched on {{ticker}}")
 
alertcondition(
     sessionExit,
     "Session Exit",
     "ElevateOne: Session ended on {{ticker}}")

← 返回列表