Market Strategies 30M Intraday Pressure Ignition

samb817 · study · 968 行 · 点赞 33 · TradingView 原页

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

Pine Script

//@version=6
indicator("Market Strategies 30M Intraday Pressure Ignition", overlay=true)
 
//============================================================
// MARKET STRATEGIES 30M INTRADAY PRESSURE IGNITION
//
// DEFAULT:
// Chart = 5 Minute
// Pressure Engine = 30 Minute
//
// 7-POINT PRESSURE ENGINE:
// 1. Volume Expansion
// 2. Range Expansion
// 3. Strong Body
// 4. Meaningful Move
// 5. Structure Break
// 6. Acceleration
// 7. Follow Through
//
// DASHBOARD:
// PRESSURE
// SCORE
// VOL
// 5M VOL
// CONTROL
// STRUCT
// VWAP
// ACCEL
//
// 5M VOL does NOT affect pressure score.
//
// ALERTS:
// BULL Pressure Confirmed
// BEAR Pressure Confirmed
// 1.50x 30M High Volume
//============================================================
 
 
//------------------------------------------------------------
// GENERAL INPUTS
//------------------------------------------------------------
 
pressureTF = input.timeframe(
     "30",
     "Pressure Timeframe")
 
minimumPrice = input.float(
     50.00,
     "Minimum Price",
     step=1.00)
 
 
//------------------------------------------------------------
// 30M VOLUME SETTINGS
//------------------------------------------------------------
 
volumeLength = input.int(
     20,
     "30M Volume Lookback",
     minval=1)
 
volumeExpansionMinimum = input.float(
     1.25,
     "30M Volume Expansion Minimum",
     step=0.05)
 
highVolumeAlertLevel = input.float(
     1.50,
     "30M High Volume Alert Level",
     step=0.05)
 
 
//------------------------------------------------------------
// 5M VOLUME SETTINGS
//------------------------------------------------------------
 
fiveMinVolumeTF = input.timeframe(
     "5",
     "Short-Term Volume Timeframe")
 
fiveMinVolumeIncreaseMinimum = input.float(
     25.0,
     "5M Volume Increase Minimum %",
     step=5.0)
 
 
//------------------------------------------------------------
// RANGE SETTINGS
//------------------------------------------------------------
 
rangeLength = input.int(
     20,
     "Range Lookback",
     minval=1)
 
rangeExpansionMinimum = input.float(
     1.20,
     "Range Expansion Minimum",
     step=0.05)
 
 
//------------------------------------------------------------
// BODY / CONTROL SETTINGS
//------------------------------------------------------------
 
minimumBodyPercent = input.float(
     0.60,
     "Minimum Body %",
     step=0.05)
 
minimumCloseLocation = input.float(
     0.70,
     "Minimum Close Location",
     step=0.05)
 
 
//------------------------------------------------------------
// MOVE SETTINGS
//------------------------------------------------------------
 
minimumBarMovePercent = input.float(
     0.35,
     "Minimum Bar Move %",
     step=0.05)
 
 
//------------------------------------------------------------
// STRUCTURE SETTINGS
//------------------------------------------------------------
 
lookbackBars = input.int(
     3,
     "Structure Lookback Bars",
     minval=1)
 
minimumBreakPercent = input.float(
     0.05,
     "Minimum Structure Break %",
     step=0.01)
 
 
//------------------------------------------------------------
// PRESSURE SCORE SETTINGS
//------------------------------------------------------------
 
minimumSignalScore = input.int(
     4,
     "Minimum Pressure Score",
     minval=1,
     maxval=7)
 
 
//------------------------------------------------------------
// DISPLAY SETTINGS
//------------------------------------------------------------
 
showDashboard = input.bool(
     true,
     "Show Dashboard")
 
showSignals = input.bool(
     true,
     "Show BULL / BEAR Labels")
 
showBackground = input.bool(
     false,
     "Highlight Active Pressure")
 
 
//============================================================
// DASHBOARD APPEARANCE
//============================================================
//
// These settings allow you to change the dashboard colors
// directly from TradingView's indicator settings.
//============================================================
 
dashboardLabelTextColor = input.color(
     color.white,
     "Dashboard Label Text")
 
dashboardLabelBackground = input.color(
     color.black,
     "Dashboard Label Background")
 
dashboardValueTextColor = input.color(
     color.white,
     "Dashboard Value Text")
 
dashboardActiveColor = input.color(
     color.orange,
     "Dashboard Active Color")
 
dashboardInactiveColor = input.color(
     color.rgb(45, 45, 45),
     "Dashboard Inactive Color")
 
 
//------------------------------------------------------------
// DASHBOARD POSITION
//------------------------------------------------------------
 
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"
     ])
 
 
//------------------------------------------------------------
// DASHBOARD SIZE
//------------------------------------------------------------
 
dashboardSize = input.string(
     "Small",
     "Dashboard Size",
     options=[
         "Tiny",
         "Small",
         "Normal"
     ])
 
 
//------------------------------------------------------------
// DASHBOARD POSITION CONVERSION
//------------------------------------------------------------
 
tablePosition =
     dashboardPosition == "Top Left" ? position.top_left :
     dashboardPosition == "Top Center" ? position.top_center :
     dashboardPosition == "Top Right" ? position.top_right :
     dashboardPosition == "Middle Left" ? position.middle_left :
     dashboardPosition == "Middle Center" ? position.middle_center :
     dashboardPosition == "Middle Right" ? position.middle_right :
     dashboardPosition == "Bottom Left" ? position.bottom_left :
     dashboardPosition == "Bottom Center" ? position.bottom_center :
     position.bottom_right
 
 
//------------------------------------------------------------
// DASHBOARD SIZE CONVERSION
//------------------------------------------------------------
 
tableTextSize =
     dashboardSize == "Tiny" ? size.tiny :
     dashboardSize == "Small" ? size.small :
     size.normal
 
 
//============================================================
// 30M PRESSURE DATA
//============================================================
 
[oHTF, hHTF, lHTF, cHTF, vHTF] = request.security(
     syminfo.tickerid,
     pressureTF,
     [open, high, low, close, volume],
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
 
//------------------------------------------------------------
// PREVIOUS COMPLETED 30M CANDLE
//------------------------------------------------------------
 
[prevO, prevH, prevL, prevC] = request.security(
     syminfo.tickerid,
     pressureTF,
     [open[1], high[1], low[1], close[1]],
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
 
//============================================================
// PRICE FILTER
//============================================================
 
priceOK =
     cHTF >= minimumPrice
 
 
//============================================================
// 1. 30M VOLUME EXPANSION
//============================================================
 
priorAverageVolume = request.security(
     syminfo.tickerid,
     pressureTF,
     ta.sma(volume[1], volumeLength),
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
volumeRatio =
     priorAverageVolume > 0 ?
     vHTF / priorAverageVolume :
     0.0
 
volumeExpansion =
     volumeRatio >= volumeExpansionMinimum
 
highVolume =
     volumeRatio >= highVolumeAlertLevel
 
 
//============================================================
// 30M HIGH VOLUME CROSS
//============================================================
 
highVolumeCross =
     highVolume and
     not highVolume[1]
 
 
//============================================================
// 5M VOLUME CHANGE
//
// Current developing 5M candle vs previous completed 5M.
//
// Informational only.
// Does NOT affect 7-point score.
//============================================================
 
current5MVolume = request.security(
     syminfo.tickerid,
     fiveMinVolumeTF,
     volume,
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
previous5MVolume = request.security(
     syminfo.tickerid,
     fiveMinVolumeTF,
     volume[1],
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
fiveMinVolumeChange =
     previous5MVolume > 0 ?
     100 * (current5MVolume / previous5MVolume - 1) :
     0.0
 
fiveMinVolumeIncreasing =
     fiveMinVolumeChange >= fiveMinVolumeIncreaseMinimum
 
 
//============================================================
// 2. RANGE EXPANSION
//============================================================
 
currentRange =
     hHTF - lHTF
 
priorAverageRange = request.security(
     syminfo.tickerid,
     pressureTF,
     ta.sma((high - low)[1], rangeLength),
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
rangeRatio =
     priorAverageRange > 0 ?
     currentRange / priorAverageRange :
     0.0
 
rangeExpansion =
     rangeRatio >= rangeExpansionMinimum
 
 
//============================================================
// 3. BODY STRENGTH
//============================================================
 
bodySize =
     math.abs(cHTF - oHTF)
 
bodyPercent =
     currentRange > 0 ?
     bodySize / currentRange :
     0.0
 
strongBody =
     bodyPercent >= minimumBodyPercent
 
 
//============================================================
// DIRECTION
//============================================================
 
bullishCandle =
     cHTF > oHTF
 
bearishCandle =
     cHTF < oHTF
 
 
//============================================================
// CLOSE LOCATION
//============================================================
 
bullCloseLocation =
     currentRange > 0 ?
     (cHTF - lHTF) / currentRange :
     0.50
 
bearCloseLocation =
     currentRange > 0 ?
     (hHTF - cHTF) / currentRange :
     0.50
 
strongBullClose =
     bullishCandle and
     bullCloseLocation >= minimumCloseLocation
 
strongBearClose =
     bearishCandle and
     bearCloseLocation >= minimumCloseLocation
 
 
//============================================================
// CONTROL
//
// BULL:
// Strong body + close near top.
//
// BEAR:
// Strong body + close near bottom.
//============================================================
 
bullControl =
     bullishCandle and
     strongBody and
     strongBullClose
 
bearControl =
     bearishCandle and
     strongBody and
     strongBearClose
 
controlQualified =
     bullControl or
     bearControl
 
 
//============================================================
// 4. MEANINGFUL 30M MOVE
//============================================================
 
barMovePercent =
     oHTF > 0 ?
     100 * math.abs(cHTF / oHTF - 1) :
     0.0
 
meaningfulBarMove =
     barMovePercent >= minimumBarMovePercent
 
 
//============================================================
// 5. STRUCTURE BREAK
//============================================================
 
recentHigh = request.security(
     syminfo.tickerid,
     pressureTF,
     ta.highest(high[1], lookbackBars),
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
recentLow = request.security(
     syminfo.tickerid,
     pressureTF,
     ta.lowest(low[1], lookbackBars),
     gaps=barmerge.gaps_off,
     lookahead=barmerge.lookahead_off)
 
bullishBreak =
     bullishCandle and
     cHTF >
     recentHigh *
     (1 + minimumBreakPercent / 100)
 
bearishBreak =
     bearishCandle and
     cHTF <
     recentLow *
     (1 - minimumBreakPercent / 100)
 
shortTermBreak =
     bullishBreak or
     bearishBreak
 
 
//============================================================
// VWAP ALIGNMENT
//============================================================
 
vwapValue =
     ta.vwap(hlc3)
 
bullishVWAP =
     bullishCandle and
     close > vwapValue
 
bearishVWAP =
     bearishCandle and
     close < vwapValue
 
vwapAligned =
     bullishVWAP or
     bearishVWAP
 
 
//============================================================
// 6. ACCELERATION
//
// Current developing 30M body > previous 30M body.
//============================================================
 
currentBodyMove =
     math.abs(cHTF - oHTF)
 
previousBodyMove =
     math.abs(prevC - prevO)
 
accelerating =
     currentBodyMove >
     previousBodyMove
 
 
//============================================================
// 7. FOLLOW THROUGH
//============================================================
 
bullFollowThrough =
     bullishCandle and
     cHTF > prevC and
     hHTF > prevH
 
bearFollowThrough =
     bearishCandle and
     cHTF < prevC and
     lHTF < prevL
 
followThrough =
     bullFollowThrough or
     bearFollowThrough
 
 
//============================================================
// FULL 7-POINT PRESSURE SCORE
//
// 1 Volume Expansion
// 1 Range Expansion
// 1 Strong Body
// 1 Meaningful Move
// 1 Structure Break
// 1 Acceleration
// 1 Follow Through
//
// 5M VOL remains informational.
//============================================================
 
signalScore =
     (volumeExpansion ? 1 : 0) +
     (rangeExpansion ? 1 : 0) +
     (strongBody ? 1 : 0) +
     (meaningfulBarMove ? 1 : 0) +
     (shortTermBreak ? 1 : 0) +
     (accelerating ? 1 : 0) +
     (followThrough ? 1 : 0)
 
 
//============================================================
// FINAL BULL / BEAR PRESSURE
//============================================================
 
bullishPressure =
     priceOK and
     strongBullClose and
     bullishVWAP and
     signalScore >= minimumSignalScore
 
bearishPressure =
     priceOK and
     strongBearClose and
     bearishVWAP and
     signalScore >= minimumSignalScore
 
 
//============================================================
// LIVE PRESSURE LABEL DETECTION
//============================================================
 
newBullPressure =
     bullishPressure and
     not bullishPressure[1]
 
newBearPressure =
     bearishPressure and
     not bearishPressure[1]
 
 
//============================================================
// TRACK PRESSURE EVENT
//============================================================
 
var bool bullTriggeredThisBar = false
var bool bearTriggeredThisBar = false
 
if barstate.isnew
    bullTriggeredThisBar := false
    bearTriggeredThisBar := false
 
if newBullPressure
    bullTriggeredThisBar := true
 
if newBearPressure
    bearTriggeredThisBar := true
 
 
//============================================================
// LIVE BULL / BEAR LABELS
//============================================================
 
plotshape(
     showSignals and newBullPressure,
     title="Bull Pressure",
     text="BULL",
     style=shape.labelup,
     location=location.belowbar,
     color=color.green,
     textcolor=color.white,
     size=size.tiny)
 
plotshape(
     showSignals and newBearPressure,
     title="Bear Pressure",
     text="BEAR",
     style=shape.labeldown,
     location=location.abovebar,
     color=color.red,
     textcolor=color.white,
     size=size.tiny)
 
 
//============================================================
// CONFIRMED PRESSURE ALERTS
//============================================================
 
confirmedBullAlert =
     bullTriggeredThisBar and
     bullishPressure and
     barstate.isconfirmed
 
confirmedBearAlert =
     bearTriggeredThisBar and
     bearishPressure and
     barstate.isconfirmed
 
 
//============================================================
// ALERT CONDITIONS
//============================================================
 
alertcondition(
     confirmedBullAlert,
     title="Market Strategies BULL Pressure Confirmed",
     message="Market Strategies 30M BULL pressure confirmed at candle close: {{ticker}}")
 
alertcondition(
     confirmedBearAlert,
     title="Market Strategies BEAR Pressure Confirmed",
     message="Market Strategies 30M BEAR pressure confirmed at candle close: {{ticker}}")
 
alertcondition(
     highVolumeCross,
     title="Market Strategies 1.50x High Volume",
     message="Market Strategies 30M volume has exceeded 1.50x average: {{ticker}}")
 
 
//============================================================
// OPTIONAL PRESSURE BACKGROUND
//============================================================
 
pressureBG =
     bullishPressure ?
     color.new(color.green, 88) :
     bearishPressure ?
     color.new(color.red, 88) :
     na
 
bgcolor(
     showBackground ?
     pressureBG :
     na)
 
 
//============================================================
// COMPACT 8-ROW DASHBOARD
//============================================================
 
var table dash = table.new(
     tablePosition,
     2,
     8,
     border_width=1)
 
 
//============================================================
// DASHBOARD
//============================================================
 
if barstate.islast and showDashboard
 
    //--------------------------------------------------------
    // PRESSURE
    //--------------------------------------------------------
 
    pressureText =
         bullishPressure ? "BULL" :
         bearishPressure ? "BEAR" :
         bullishCandle ? "BUILD BULL" :
         bearishCandle ? "BUILD BEAR" :
         "NEUTRAL"
 
    pressureQualified =
         bullishPressure or
         bearishPressure
 
    table.cell(
         dash, 0, 0,
         "PRESSURE",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 0,
         pressureText,
         text_color=dashboardValueTextColor,
         bgcolor=pressureQualified ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
    //--------------------------------------------------------
    // SCORE
    //--------------------------------------------------------
 
    table.cell(
         dash, 0, 1,
         "SCORE",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 1,
         str.tostring(signalScore) + "/7",
         text_color=dashboardValueTextColor,
         bgcolor=signalScore >= minimumSignalScore ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
    //--------------------------------------------------------
    // 30M VOLUME
    //--------------------------------------------------------
 
    table.cell(
         dash, 0, 2,
         "VOL",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 2,
         str.tostring(volumeRatio, "#.##") + "x",
         text_color=dashboardValueTextColor,
         bgcolor=volumeExpansion ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
    //--------------------------------------------------------
    // 5M VOLUME
    //--------------------------------------------------------
 
    fiveMinVolumeText =
         fiveMinVolumeChange > 0 ?
         "+" + str.tostring(fiveMinVolumeChange, "#") + "% ↑" :
         fiveMinVolumeChange < 0 ?
         str.tostring(fiveMinVolumeChange, "#") + "% ↓" :
         "0%"
 
    table.cell(
         dash, 0, 3,
         "5M VOL",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 3,
         fiveMinVolumeText,
         text_color=dashboardValueTextColor,
         bgcolor=fiveMinVolumeIncreasing ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
    //--------------------------------------------------------
    // CONTROL
    //--------------------------------------------------------
 
    controlText =
         bullControl ? "BULL CTRL" :
         bearControl ? "BEAR CTRL" :
         bullishCandle ? "BUILD BULL" :
         bearishCandle ? "BUILD BEAR" :
         "NO CTRL"
 
    table.cell(
         dash, 0, 4,
         "CONTROL",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 4,
         controlText,
         text_color=dashboardValueTextColor,
         bgcolor=controlQualified ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
    //--------------------------------------------------------
    // STRUCTURE
    //--------------------------------------------------------
 
    structureText =
         bullishBreak ? "BULL BRK" :
         bearishBreak ? "BEAR BRK" :
         "NO BRK"
 
    table.cell(
         dash, 0, 5,
         "STRUCT",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 5,
         structureText,
         text_color=dashboardValueTextColor,
         bgcolor=shortTermBreak ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
    //--------------------------------------------------------
    // VWAP
    //--------------------------------------------------------
 
    vwapText =
         bullishVWAP ? "ABOVE" :
         bearishVWAP ? "BELOW" :
         "NO"
 
    table.cell(
         dash, 0, 6,
         "VWAP",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 6,
         vwapText,
         text_color=dashboardValueTextColor,
         bgcolor=vwapAligned ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
    //--------------------------------------------------------
    // ACCELERATION
    //--------------------------------------------------------
 
    table.cell(
         dash, 0, 7,
         "ACCEL",
         text_color=dashboardLabelTextColor,
         bgcolor=dashboardLabelBackground,
         text_size=tableTextSize)
 
    table.cell(
         dash, 1, 7,
         accelerating ? "YES" : "NO",
         text_color=dashboardValueTextColor,
         bgcolor=accelerating ?
             dashboardActiveColor :
             dashboardInactiveColor,
         text_size=tableTextSize)
 
 
//============================================================
// DATA WINDOW
//============================================================
 
plot(
     signalScore,
     title="Market Strategies Pressure Score",
     display=display.data_window)
 
plot(
     volumeRatio,
     title="Market Strategies 30M Volume Ratio",
     display=display.data_window)
 
plot(
     fiveMinVolumeChange,
     title="Market Strategies 5M Volume Change %",
     display=display.data_window)
 
plot(
     rangeRatio,
     title="Market Strategies Range Ratio",
     display=display.data_window)
 
plot(
     bodyPercent * 100,
     title="Market Strategies Body %",
     display=display.data_window)
 
plot(
     barMovePercent,
     title="Market Strategies HTF Move %",
     display=display.data_window)
 
plot(
     bullCloseLocation * 100,
     title="Market Strategies Bull Close Location %",
     display=display.data_window)
 
plot(
     bearCloseLocation * 100,
     title="Market Strategies Bear Close Location %",
     display=display.data_window)

← 返回列表