NASDAQ EXPECTED VOLATILITY

nasdaqsniper21 · study · 1224 行 · 点赞 10 · TradingView 原页

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

Pine Script

//@version=6
indicator("NASDAQ EXPECTED VOLATILITY", overlay=true, max_lines_count=100, max_labels_count=100)
 
//=====================================================================
// 01 — VOLATILITY ENGINE
//=====================================================================
 
groupVol = "01 — VOLATILITY ENGINE"
 
volMode = input.string(
     "Manual EM",
     "Volatility Mode",
     options=["IV Calculated", "Manual EM"],
     group=groupVol)
 
atmIV = input.float(
     18.0,
     "ATM IV (%)",
     minval=0.1,
     step=0.1,
     group=groupVol)
 
vxn = input.float(
     21.0,
     "VXN Proxy (%)",
     minval=0.1,
     step=0.1,
     group=groupVol)
 
useVXNProxy = input.bool(
     false,
     "Use VXN as IV Proxy",
     group=groupVol)
 
dailyEMManual = input.float(
     383.5,
     "Daily EM",
     minval=0,
     step=0.25,
     group=groupVol)
 
weeklyEMManual = input.float(
     751.0,
     "Weekly EM",
     minval=0,
     step=0.25,
     group=groupVol)
 
monthlyEMManual = input.float(
     1750.0,
     "Monthly EM",
     minval=0,
     step=0.25,
     group=groupVol)
 
halfEM = input.float(
     0.50,
     "Half EM Multiplier",
     minval=0,
     step=0.05,
     group=groupVol)
 
quarterEM = input.float(
     0.25,
     "Quarter EM Multiplier",
     minval=0,
     step=0.05,
     group=groupVol)
 
 
//=====================================================================
// 02 — SESSION / REFERENCE
//=====================================================================
 
groupSession = "02 — SESSION / REFERENCE"
 
rthSession = input.session(
     "0930-1600",
     "RTH Session",
     group=groupSession)
 
globexSession = input.session(
     "1800-0930",
     "6 PM Globex Session",
     group=groupSession)
 
orbMinutes = input.int(
     15,
     "ORB Minutes",
     minval=1,
     maxval=60,
     group=groupSession)
 
sessionTZ = input.string(
     "America/New_York",
     "Session Time Zone",
     group=groupSession)
 
useRTHOpen = input.bool(
     true,
     "Use RTH Open",
     group=groupSession)
 
manualReference = input.float(
     0.0,
     "Manual Reference",
     step=0.25,
     group=groupSession)
 
useSixPM = input.bool(
     true,
     "Track 6 PM Globex",
     group=groupSession)
 
manualSixPM = input.float(
     0.0,
     "Manual 6 PM Reference",
     step=0.25,
     group=groupSession)
 
 
//=====================================================================
// 03 — STRUCTURE
//=====================================================================
 
groupStructure = "03 — MARKET STRUCTURE"
 
showVWAP = input.bool(
     true,
     "Show VWAP",
     group=groupStructure)
 
showORB = input.bool(
     true,
     "Show Body-Based ORB",
     group=groupStructure)
 
showPDLevels = input.bool(
     true,
     "Show PDH / PDL",
     group=groupStructure)
 
showPrevClose = input.bool(
     true,
     "Show Previous Close",
     group=groupStructure)
 
 
//=====================================================================
// 04 — RISK
//=====================================================================
 
groupRisk = "04 — RISK"
 
showRiskLevels = input.bool(
     false,
     "Show Risk Levels",
     group=groupRisk)
 
riskTicks = input.int(
     120,
     "Risk Ticks",
     minval=1,
     group=groupRisk)
 
nqTickSize = input.float(
     0.25,
     "NQ Tick Size",
     step=0.25,
     group=groupRisk)
 
risk1RMultiplier = input.float(
     1.0,
     "1R Multiplier",
     step=0.25,
     group=groupRisk)
 
risk2RMultiplier = input.float(
     2.0,
     "2R Multiplier",
     step=0.25,
     group=groupRisk)
 
 
//=====================================================================
// 05 — DASHBOARD
//=====================================================================
 
groupDash = "05 — DASHBOARD"
 
showDashboard = input.bool(
     true,
     "Show Dashboard",
     group=groupDash)
 
dashboardPosition = input.string(
     "Top Right",
     "Dashboard Position",
     options=[
         "Top Left",
         "Top Center",
         "Top Right",
         "Middle Left",
         "Middle Center",
         "Middle Right",
         "Bottom Left",
         "Bottom Center",
         "Bottom Right"
     ],
     group=groupDash)
 
dashboardSize = input.string(
     "Small",
     "Dashboard Size",
     options=["Tiny", "Small", "Normal", "Large"],
     group=groupDash)
 
 
//=====================================================================
// 06 — CHART LEVELS
//=====================================================================
 
groupChart = "06 — CHART LEVELS"
 
showChartLevels = input.bool(
     true,
     "Show Chart Levels",
     group=groupChart)
 
showDailyEM = input.bool(
     true,
     "Daily EM",
     group=groupChart)
 
showWeeklyEM = input.bool(
     true,
     "Weekly EM",
     group=groupChart)
 
showMonthlyEM = input.bool(
     true,
     "Monthly EM",
     group=groupChart)
 
showDailyHalf = input.bool(
     true,
     "Daily Half EM",
     group=groupChart)
 
showDailyQuarter = input.bool(
     true,
     "Daily Quarter EM",
     group=groupChart)
 
showRTHLine = input.bool(
     true,
     "RTH Open",
     group=groupChart)
 
showSixPMLine = input.bool(
     true,
     "6 PM Reference",
     group=groupChart)
 
 
//=====================================================================
// 07 — PRICE LABELS
//=====================================================================
 
groupLabels = "07 — PRICE LABELS"
 
showPriceLabels = input.bool(
     true,
     "Show Price Labels",
     group=groupLabels)
 
labelOffsetBars = input.int(
     1,
     "Label Offset",
     minval=0,
     maxval=20,
     group=groupLabels)
 
labelSizeInput = input.string(
     "Small",
     "Label Size",
     options=["Tiny", "Small", "Normal", "Large"],
     group=groupLabels)
 
showLabelNames = input.bool(
     true,
     "Show Level Names",
     group=groupLabels)
 
showLabelPrices = input.bool(
     true,
     "Show Prices",
     group=groupLabels)
 
 
//=====================================================================
// 08 — COLORS
//=====================================================================
 
groupColors = "08 — COLORS"
 
dailyColor = input.color(
     color.red,
     "Daily EM",
     group=groupColors)
 
halfColor = input.color(
     color.orange,
     "Half EM",
     group=groupColors)
 
quarterColor = input.color(
     color.yellow,
     "Quarter EM",
     group=groupColors)
 
weeklyColor = input.color(
     color.purple,
     "Weekly EM",
     group=groupColors)
 
monthlyColor = input.color(
     color.fuchsia,
     "Monthly EM",
     group=groupColors)
 
rthColor = input.color(
     color.white,
     "RTH Open",
     group=groupColors)
 
sixPMColor = input.color(
     color.gray,
     "6 PM",
     group=groupColors)
 
vwapColor = input.color(
     color.aqua,
     "VWAP",
     group=groupColors)
 
orbColor = input.color(
     color.orange,
     "ORB",
     group=groupColors)
 
pdColor = input.color(
     color.blue,
     "PDH / PDL",
     group=groupColors)
 
prevCloseColor = input.color(
     color.gray,
     "Previous Close",
     group=groupColors)
 
riskColor = input.color(
     color.white,
     "Risk",
     group=groupColors)
 
 
//=====================================================================
// 09 — LINE WIDTH
//=====================================================================
 
groupStyle = "09 — LINE STYLE"
 
mainLineWidth = input.int(
     2,
     "Main EM Width",
     minval=1,
     maxval=5,
     group=groupStyle)
 
halfLineWidth = input.int(
     1,
     "Half EM Width",
     minval=1,
     maxval=5,
     group=groupStyle)
 
quarterLineWidth = input.int(
     1,
     "Quarter EM Width",
     minval=1,
     maxval=5,
     group=groupStyle)
 
 
//=====================================================================
// HELPER FUNCTIONS
//=====================================================================
 
f_tablePosition(_position) =>
    switch _position
        "Top Left"      => position.top_left
        "Top Center"    => position.top_center
        "Top Right"     => position.top_right
        "Middle Left"   => position.middle_left
        "Middle Center" => position.middle_center
        "Middle Right"  => position.middle_right
        "Bottom Left"   => position.bottom_left
        "Bottom Center" => position.bottom_center
        => position.bottom_right
 
 
f_tableSize(_size) =>
    switch _size
        "Tiny"   => size.tiny
        "Small"  => size.small
        "Normal" => size.normal
        => size.large
 
 
f_labelSize(_size) =>
    switch _size
        "Tiny"   => size.tiny
        "Small"  => size.small
        "Normal" => size.normal
        => size.large
 
 
f_price(_price) =>
    str.tostring(_price, format.mintick)
 
 
f_labelText(_name, _price) =>
    string result = ""
 
    if showLabelNames
        result += _name
 
    if showLabelPrices
        if str.length(result) > 0
            result += "  "
        result += f_price(_price)
 
    result
 
 
//=====================================================================
// SESSION DETECTION
//=====================================================================
 
inRTH = not na(time(timeframe.period, rthSession, sessionTZ))
inGlobex = not na(time(timeframe.period, globexSession, sessionTZ))
 
newRTH = inRTH and not inRTH[1]
newGlobex = inGlobex and not inGlobex[1]
 
 
//=====================================================================
// RTH / 6 PM REFERENCES
//=====================================================================
 
var float rthOpen = na
var float sixPMReference = na
 
if newRTH
    rthOpen := open
 
if newGlobex
    sixPMReference := open
 
if not useSixPM
    sixPMReference := na
 
reference =
     useRTHOpen and not na(rthOpen) ?
         rthOpen :
     manualReference > 0 ?
         manualReference :
         open
 
sixPMAnchor =
     useSixPM and not na(sixPMReference) ?
         sixPMReference :
     manualSixPM > 0 ?
         manualSixPM :
         na
 
 
//=====================================================================
// VOLATILITY ENGINE
//=====================================================================
 
effectiveIV = useVXNProxy ? vxn / 100.0 : atmIV / 100.0
 
dailyEMIV =
     reference * effectiveIV / math.sqrt(252)
 
weeklyEMIV =
     reference * effectiveIV * math.sqrt(5.0 / 252.0)
 
monthlyEMIV =
     reference * effectiveIV * math.sqrt(21.0 / 252.0)
 
dailyEM =
     volMode == "IV Calculated" ?
         dailyEMIV :
         dailyEMManual
 
weeklyEM =
     volMode == "IV Calculated" ?
         weeklyEMIV :
         weeklyEMManual
 
monthlyEM =
     volMode == "IV Calculated" ?
         monthlyEMIV :
         monthlyEMManual
 
 
//=====================================================================
// DAILY LEVELS
//=====================================================================
 
dailyUpper = reference + dailyEM
dailyLower = reference - dailyEM
 
dailyHalfUpper = reference + dailyEM * halfEM
dailyHalfLower = reference - dailyEM * halfEM
 
dailyQuarterUpper = reference + dailyEM * quarterEM
dailyQuarterLower = reference - dailyEM * quarterEM
 
 
//=====================================================================
// WEEKLY LEVELS
//=====================================================================
 
weeklyUpper = reference + weeklyEM
weeklyLower = reference - weeklyEM
 
 
//=====================================================================
// MONTHLY LEVELS
//=====================================================================
 
monthlyUpper = reference + monthlyEM
monthlyLower = reference - monthlyEM
 
 
//=====================================================================
// 6 PM LEVELS
//=====================================================================
 
sixPMUpper = not na(sixPMAnchor) ? sixPMAnchor + dailyEM : na
sixPMLower = not na(sixPMAnchor) ? sixPMAnchor - dailyEM : na
 
 
//=====================================================================
// VWAP
//=====================================================================
 
vwapValue = ta.vwap(hlc3)
 
 
//=====================================================================
// PREVIOUS DAY LEVELS
//=====================================================================
 
pdHigh = request.security(
     syminfo.tickerid,
     "D",
     high[1],
     lookahead=barmerge.lookahead_on)
 
pdLow = request.security(
     syminfo.tickerid,
     "D",
     low[1],
     lookahead=barmerge.lookahead_on)
 
prevClose = request.security(
     syminfo.tickerid,
     "D",
     close[1],
     lookahead=barmerge.lookahead_on)
 
 
//=====================================================================
// BODY-BASED ORB
//=====================================================================
//
// IMPORTANT:
// This ORB intentionally uses OPEN and CLOSE only.
// WICKS ARE IGNORED.
//
// Example:
// Open  = 30,500
// Close = 30,700
// ORB   = 30,500 — 30,700
//
//=====================================================================
 
var float orbBodyHigh = na
var float orbBodyLow = na
var int orbStartTime = na
var int orbEndTime = na
 
if newRTH
    orbStartTime := time
    orbEndTime := time + orbMinutes * 60 * 1000
 
    orbBodyHigh := math.max(open, close)
    orbBodyLow := math.min(open, close)
 
inORB = inRTH and
     not na(orbStartTime) and
     time < orbEndTime
 
if inORB
    orbBodyHigh := math.max(orbBodyHigh, math.max(open, close))
    orbBodyLow := math.min(orbBodyLow, math.min(open, close))
 
orbComplete =
     inRTH and
     not inORB and
     not na(orbBodyHigh)
 
 
//=====================================================================
// REALIZED RANGE
//=====================================================================
 
var float dailyRTHHigh = na
var float dailyRTHLow = na
 
if newRTH
    dailyRTHHigh := high
    dailyRTHLow := low
 
if inRTH
    dailyRTHHigh := math.max(dailyRTHHigh, high)
    dailyRTHLow := math.min(dailyRTHLow, low)
 
dailyRealizedRange =
     not na(dailyRTHHigh) and not na(dailyRTHLow) ?
         dailyRTHHigh - dailyRTHLow :
         na
 
moveFromRTHOpen =
     not na(rthOpen) ?
         close - rthOpen :
         na
 
 
//=====================================================================
// RISK GEOMETRY
//=====================================================================
 
oneRPoints = riskTicks * nqTickSize * risk1RMultiplier
twoRPoints = riskTicks * nqTickSize * risk2RMultiplier
 
riskUpper1R = close + oneRPoints
riskLower1R = close - oneRPoints
 
riskUpper2R = close + twoRPoints
riskLower2R = close - twoRPoints
 
 
//=====================================================================
// LOCATION
//=====================================================================
 
dailyLocation =
     close >= dailyUpper ? "+1.00 EM+" :
     close >= dailyHalfUpper ? "+0.50 to +1.00" :
     close >= dailyQuarterUpper ? "+0.25 to +0.50" :
     close >= reference ? "0 to +0.25" :
     close >= dailyQuarterLower ? "0 to -0.25" :
     close >= dailyHalfLower ? "-0.25 to -0.50" :
     close >= dailyLower ? "-0.50 to -1.00" :
     "-1.00 EM-"
 
 
//=====================================================================
// CHART PLOTS
//=====================================================================
 
plot(
     showChartLevels and showDailyEM ? dailyUpper : na,
     "Daily +1 EM",
     color=dailyColor,
     linewidth=mainLineWidth)
 
plot(
     showChartLevels and showDailyEM ? dailyLower : na,
     "Daily -1 EM",
     color=dailyColor,
     linewidth=mainLineWidth)
 
plot(
     showChartLevels and showDailyHalf ? dailyHalfUpper : na,
     "Daily +0.50 EM",
     color=halfColor,
     linewidth=halfLineWidth)
 
plot(
     showChartLevels and showDailyHalf ? dailyHalfLower : na,
     "Daily -0.50 EM",
     color=halfColor,
     linewidth=halfLineWidth)
 
plot(
     showChartLevels and showDailyQuarter ? dailyQuarterUpper : na,
     "Daily +0.25 EM",
     color=quarterColor,
     linewidth=quarterLineWidth)
 
plot(
     showChartLevels and showDailyQuarter ? dailyQuarterLower : na,
     "Daily -0.25 EM",
     color=quarterColor,
     linewidth=quarterLineWidth)
 
plot(
     showChartLevels and showWeeklyEM ? weeklyUpper : na,
     "Weekly +1 EM",
     color=weeklyColor,
     linewidth=mainLineWidth)
 
plot(
     showChartLevels and showWeeklyEM ? weeklyLower : na,
     "Weekly -1 EM",
     color=weeklyColor,
     linewidth=mainLineWidth)
 
plot(
     showChartLevels and showMonthlyEM ? monthlyUpper : na,
     "Monthly +1 EM",
     color=monthlyColor,
     linewidth=mainLineWidth)
 
plot(
     showChartLevels and showMonthlyEM ? monthlyLower : na,
     "Monthly -1 EM",
     color=monthlyColor,
     linewidth=mainLineWidth)
 
plot(
     showChartLevels and showRTHLine ? rthOpen : na,
     "RTH Open",
     color=rthColor,
     linewidth=2)
 
plot(
     showChartLevels and showSixPMLine ? sixPMReference : na,
     "6 PM Globex",
     color=sixPMColor,
     linewidth=2)
 
plot(
     showChartLevels and showVWAP ? vwapValue : na,
     "VWAP",
     color=vwapColor,
     linewidth=2)
 
plot(
     showChartLevels and showORB and orbComplete ? orbBodyHigh : na,
     "ORB Body High",
     color=orbColor,
     linewidth=2)
 
plot(
     showChartLevels and showORB and orbComplete ? orbBodyLow : na,
     "ORB Body Low",
     color=orbColor,
     linewidth=2)
 
plot(
     showChartLevels and showPDLevels ? pdHigh : na,
     "PDH",
     color=pdColor,
     linewidth=1)
 
plot(
     showChartLevels and showPDLevels ? pdLow : na,
     "PDL",
     color=pdColor,
     linewidth=1)
 
plot(
     showChartLevels and showPrevClose ? prevClose : na,
     "Previous Close",
     color=prevCloseColor,
     linewidth=1)
 
plot(
     showChartLevels and showRiskLevels ? riskUpper1R : na,
     "1R Upper",
     color=riskColor,
     linewidth=1)
 
plot(
     showChartLevels and showRiskLevels ? riskLower1R : na,
     "1R Lower",
     color=riskColor,
     linewidth=1)
 
plot(
     showChartLevels and showRiskLevels ? riskUpper2R : na,
     "2R Upper",
     color=riskColor,
     linewidth=1)
 
plot(
     showChartLevels and showRiskLevels ? riskLower2R : na,
     "2R Lower",
     color=riskColor,
     linewidth=1)
 
 
//=====================================================================
// PRICE LABEL ENGINE
//=====================================================================
//
// The important part:
// Labels are recreated ONLY on the latest bar.
// This prevents thousands of labels from accumulating.
//
//=====================================================================
 
var label[] priceLabels = array.new_label()
 
f_deleteLabels() =>
    if array.size(priceLabels) > 0
        for i = array.size(priceLabels) - 1 to 0
            label.delete(array.get(priceLabels, i))
        array.clear(priceLabels)
 
 
f_addPriceLabel(_name, _price, _color) =>
    if showPriceLabels and showChartLevels and not na(_price)
        label newLabel = label.new(
             bar_index + labelOffsetBars,
             _price,
             f_labelText(_name, _price),
             xloc=xloc.bar_index,
             yloc=yloc.price,
             style=label.style_label_left,
             textcolor=color.white,
             color=color.new(_color, 15),
             size=f_labelSize(labelSizeInput))
 
        array.push(priceLabels, newLabel)
 
 
//=====================================================================
// CREATE CURRENT PRICE LABELS
//=====================================================================
 
if barstate.islast
    f_deleteLabels()
 
    if showChartLevels
 
        // DAILY
        if showDailyEM
            f_addPriceLabel("+1D EM", dailyUpper, dailyColor)
            f_addPriceLabel("-1D EM", dailyLower, dailyColor)
 
        if showDailyHalf
            f_addPriceLabel("+0.50D EM", dailyHalfUpper, halfColor)
            f_addPriceLabel("-0.50D EM", dailyHalfLower, halfColor)
 
        if showDailyQuarter
            f_addPriceLabel("+0.25D EM", dailyQuarterUpper, quarterColor)
            f_addPriceLabel("-0.25D EM", dailyQuarterLower, quarterColor)
 
        // WEEKLY
        if showWeeklyEM
            f_addPriceLabel("+1W EM", weeklyUpper, weeklyColor)
            f_addPriceLabel("-1W EM", weeklyLower, weeklyColor)
 
        // MONTHLY
        if showMonthlyEM
            f_addPriceLabel("+1M EM", monthlyUpper, monthlyColor)
            f_addPriceLabel("-1M EM", monthlyLower, monthlyColor)
 
        // SESSION REFERENCES
        if showRTHLine
            f_addPriceLabel("RTH OPEN", rthOpen, rthColor)
 
        if showSixPMLine
            f_addPriceLabel("6 PM", sixPMReference, sixPMColor)
 
        // VWAP
        if showVWAP
            f_addPriceLabel("VWAP", vwapValue, vwapColor)
 
        // BODY ORB
        if showORB and orbComplete
            f_addPriceLabel("ORB BODY HIGH", orbBodyHigh, orbColor)
            f_addPriceLabel("ORB BODY LOW", orbBodyLow, orbColor)
 
        // PRIOR DAY
        if showPDLevels
            f_addPriceLabel("PDH", pdHigh, pdColor)
            f_addPriceLabel("PDL", pdLow, pdColor)
 
        if showPrevClose
            f_addPriceLabel("PREV CLOSE", prevClose, prevCloseColor)
 
        // RISK
        if showRiskLevels
            f_addPriceLabel("+1R", riskUpper1R, riskColor)
            f_addPriceLabel("-1R", riskLower1R, riskColor)
            f_addPriceLabel("+2R", riskUpper2R, riskColor)
            f_addPriceLabel("-2R", riskLower2R, riskColor)
 
 
//=====================================================================
// DASHBOARD
//=====================================================================
 
var table dashboard = table.new(
     f_tablePosition(dashboardPosition),
     2,
     15,
     border_width=1)
 
if barstate.islast and showDashboard
 
    table.clear(dashboard, 0, 0, 1, 14)
 
    txtSize = f_tableSize(dashboardSize)
 
    table.cell(
         dashboard,
         0,
         0,
         "NASDAQ EXPECTED VOLATILITY",
         text_color=color.white,
         bgcolor=color.new(color.black, 0),
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         0,
         "NQ",
         text_color=color.white,
         bgcolor=color.new(color.black, 0),
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         1,
         "RTH OPEN",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         1,
         f_price(rthOpen),
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         2,
         "6 PM",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         2,
         f_price(sixPMReference),
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         3,
         "DAILY EM",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         3,
         f_price(dailyEM),
         text_color=dailyColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         4,
         "WEEKLY EM",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         4,
         f_price(weeklyEM),
         text_color=weeklyColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         5,
         "MONTHLY EM",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         5,
         f_price(monthlyEM),
         text_color=monthlyColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         6,
         "LOCATION",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         6,
         dailyLocation,
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         7,
         "VWAP",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         7,
         f_price(vwapValue),
         text_color=vwapColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         8,
         "ORB BODY HIGH",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         8,
         f_price(orbBodyHigh),
         text_color=orbColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         9,
         "ORB BODY LOW",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         9,
         f_price(orbBodyLow),
         text_color=orbColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         10,
         "PDH",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         10,
         f_price(pdHigh),
         text_color=pdColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         11,
         "PDL",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         11,
         f_price(pdLow),
         text_color=pdColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         12,
         "PREV CLOSE",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         12,
         f_price(prevClose),
         text_color=prevCloseColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         13,
         "1R / 2R",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         13,
         str.tostring(oneRPoints, "#.##") +
         " / " +
         str.tostring(twoRPoints, "#.##") +
         " pts",
         text_color=riskColor,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         0,
         14,
         "CURRENT",
         text_color=color.white,
         text_size=txtSize)
 
    table.cell(
         dashboard,
         1,
         14,
         f_price(close),
         text_color=color.white,
         text_size=txtSize)
 
 
//=====================================================================
// ALERTS
//=====================================================================
 
alertcondition(
     ta.crossover(close, dailyUpper),
     "NQ Above Daily +1 EM",
     "NQ crossed above Daily +1 EM")
 
alertcondition(
     ta.crossunder(close, dailyLower),
     "NQ Below Daily -1 EM",
     "NQ crossed below Daily -1 EM")
 
alertcondition(
     ta.crossover(close, weeklyUpper),
     "NQ Above Weekly +1 EM",
     "NQ crossed above Weekly +1 EM")
 
alertcondition(
     ta.crossunder(close, weeklyLower),
     "NQ Below Weekly -1 EM",
     "NQ crossed below Weekly -1 EM")
 
alertcondition(
     ta.crossover(close, vwapValue),
     "NQ Above VWAP",
     "NQ crossed above VWAP")
 
alertcondition(
     ta.crossunder(close, vwapValue),
     "NQ Below VWAP",
     "NQ crossed below VWAP")
 
alertcondition(
     orbComplete and ta.crossover(close, orbBodyHigh),
     "NQ Above Body ORB",
     "NQ crossed above the body-based ORB high")
 
alertcondition(
     orbComplete and ta.crossunder(close, orbBodyLow),
     "NQ Below Body ORB",
     "NQ crossed below the body-based ORB low")

← 返回列表