本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("FPD", "FPD", overlay = true, max_labels_count = 500, max_lines_count = 500)
//══════════════════════════════════════════════════════════════════════════════
// 01. FOOTPRINT SETTINGS
//══════════════════════════════════════════════════════════════════════════════
groupFP = "01. Footprint"
footprintTicksPerRow = input.int(
20,
"Ticks Per Row",
minval = 1,
group = groupFP)
footprintVAPercent = input.float(
70.0,
"Value Area %",
minval = 1.0,
maxval = 100.0,
group = groupFP)
footprintImbalancePercent = input.float(
300.0,
"Imbalance %",
minval = 1.0,
group = groupFP)
//══════════════════════════════════════════════════════════════════════════════
// 03. EVENT THRESHOLDS
//══════════════════════════════════════════════════════════════════════════════
groupThreshold = "03. Event Thresholds"
initiativeDeltaPercent = input.float(
8.0,
"Initiative Delta %",
minval = 1.0,
group = groupThreshold)
absorptionDeltaPercent = input.float(
3.0,
"Absorption Delta %",
minval = 0.0,
group = groupThreshold)
minimumImbalances = input.int(
3,
"Minimum Imbalances",
minval = 1,
group = groupThreshold)
minimumRelativeVolume = input.float(
1.0,
"Minimum Relative Volume",
minval = 0.1,
group = groupThreshold)
//══════════════════════════════════════════════════════════════════════════════
// 04. MARKET LOCATION
//══════════════════════════════════════════════════════════════════════════════
groupLocation = "04. Market Location"
showLocationLevels = input.bool(
true,
"Show Location Levels",
group = groupLocation)
showPreviousDayLevels = input.bool(
true,
"Show Previous Day Levels",
group = groupLocation)
showVWAP = input.bool(
true,
"Show VWAP",
group = groupLocation)
showOpeningRange = input.bool(
true,
"Show Opening Range",
group = groupLocation)
rthSession = input.session(
"0915-1530",
"RTH Session",
group = groupLocation)
openingRangeMinutes = input.int(
15,
"Opening Range Minutes",
minval = 5,
maxval = 120,
group = groupLocation)
//══════════════════════════════════════════════════════════════════════════════
// 05. STRUCTURAL DELTA SETTINGS
//══════════════════════════════════════════════════════════════════════════════
groupStructure = "05. Structural Delta"
showStructure = input.bool(
true,
"Show Structural Signals",
group = groupStructure)
pivotLeft = input.int(
1,
"Pivot Left Bars",
minval = 1,
maxval = 20,
group = groupStructure)
pivotRight = input.int(
1,
"Pivot Confirmation Bars",
minval = 1,
maxval = 20,
group = groupStructure)
minPriceMoveATR = input.float(
0.10,
"Minimum Price Structural Move (ATR)",
minval = 0.0,
step = 0.05,
group = groupStructure)
minDeltaMovePercent = input.float(
5.0,
"Minimum Delta Structural Change %",
minval = 0.0,
step = 1.0,
group = groupStructure)
labelATRDistance = input.int(
2,
"Label Distance (ATR)",
options = [1, 2, 3],
group = groupStructure)
showLabelDelta = input.bool(
true,
"Show Delta",
group = groupStructure)
showLabelAvgDelta = input.bool(
true,
"Show Avg Delta",
group = groupStructure)
showDivergenceLines = input.bool(
true,
"Draw Divergence Lines",
group = groupStructure)
showContinuationLines = input.bool(
true,
"Draw Continuation Lines",
group = groupStructure)
//══════════════════════════════════════════════════════════════════════════════
// 06. CONTINUATION SETTINGS
//══════════════════════════════════════════════════════════════════════════════
groupContinuation = "06. Continuation"
enableContinuation = input.bool(
true,
"Enable Continuation Detection",
group = groupContinuation)
requireDeltaConfirmation = input.bool(
true,
"Require Delta Structure Confirmation",
group = groupContinuation)
showContinuationLabels = input.bool(
true,
"Show Continuation Labels",
group = groupContinuation)
//══════════════════════════════════════════════════════════════════════════════
// 07. FOOTPRINT DATA
//══════════════════════════════════════════════════════════════════════════════
footprint fp = request.footprint(
footprintTicksPerRow,
footprintVAPercent,
footprintImbalancePercent)
float buyVolume = na
float sellVolume = na
float totalVolume = na
float delta = na
int buyImbalances = 0
int sellImbalances = 0
if not na(fp)
buyVolume := fp.buy_volume()
sellVolume := fp.sell_volume()
totalVolume := fp.total_volume()
delta := fp.delta()
for row in fp.rows()
if row.has_buy_imbalance()
buyImbalances += 1
if row.has_sell_imbalance()
sellImbalances += 1
//══════════════════════════════════════════════════════════════════════════════
// 08. BASIC DATA
//══════════════════════════════════════════════════════════════════════════════
atr = ta.atr(14)
avgVolume = ta.sma(volume, 20)
relativeVolume =
avgVolume > 0 ?
volume / avgVolume :
na
deltaPercent =
not na(totalVolume) and totalVolume > 0 ?
delta / totalVolume * 100.0 :
na
barRange = high - low
body = math.abs(close - open)
bodyRatio =
barRange > 0 ?
body / barRange :
0.0
upperWick =
high - math.max(open, close)
lowerWick =
math.min(open, close) - low
upperWickRatio =
barRange > 0 ?
upperWick / barRange :
0.0
lowerWickRatio =
barRange > 0 ?
lowerWick / barRange :
0.0
//══════════════════════════════════════════════════════════════════════════════
// 09. RTH SESSION
//══════════════════════════════════════════════════════════════════════════════
newDay = ta.change(time("D")) != 0
bool inRTH =
not na(time(timeframe.period, rthSession))
bool newRTH =
inRTH and
(not inRTH[1] or newDay)
//══════════════════════════════════════════════════════════════════════════════
// 10. SESSION CUMULATIVE DELTA
//══════════════════════════════════════════════════════════════════════════════
var float cumulativeDelta = 0.0
var float cumulativeAbsDelta = 0.0
var int sessionDeltaBars = 0
var float previousSessionAvgAbsDelta = na
if newRTH
if sessionDeltaBars > 0
previousSessionAvgAbsDelta := cumulativeAbsDelta / sessionDeltaBars
cumulativeDelta := nz(delta, 0.0)
cumulativeAbsDelta := nz(math.abs(delta), 0.0)
sessionDeltaBars := not na(delta) ? 1 : 0
else if inRTH and not na(delta)
cumulativeDelta += delta
cumulativeAbsDelta += math.abs(delta)
sessionDeltaBars += 1
float averageAbsDelta =
sessionDeltaBars > 0 ?
cumulativeAbsDelta / sessionDeltaBars :
na
//══════════════════════════════════════════════════════════════════════════════
// 11. RTH OPEN
//══════════════════════════════════════════════════════════════════════════════
var float rthOpen = na
if newRTH
rthOpen := open
//══════════════════════════════════════════════════════════════════════════════
// 12. OPENING RANGE
//══════════════════════════════════════════════════════════════════════════════
var int rthStartTime = na
var float openingRangeHigh = na
var float openingRangeLow = na
if newRTH
rthStartTime := time
openingRangeHigh := high
openingRangeLow := low
bool openingRangeActive =
inRTH and
not na(rthStartTime) and
time < rthStartTime + openingRangeMinutes * 60 * 1000
if openingRangeActive
openingRangeHigh :=
math.max(openingRangeHigh, high)
openingRangeLow :=
math.min(openingRangeLow, low)
//══════════════════════════════════════════════════════════════════════════════
// 13. RTH VWAP
//══════════════════════════════════════════════════════════════════════════════
var float sessionPV = na
var float sessionVolume = na
if newRTH
sessionPV := hlc3 * volume
sessionVolume := volume
else if inRTH
sessionPV += hlc3 * volume
sessionVolume += volume
float sessionVWAP =
inRTH and
not na(sessionVolume) and
sessionVolume > 0 ?
sessionPV / sessionVolume :
na
//══════════════════════════════════════════════════════════════════════════════
// 14. PREVIOUS DAY LEVELS
//══════════════════════════════════════════════════════════════════════════════
previousDayHigh =
request.security(
syminfo.tickerid,
"D",
high[1],
lookahead = barmerge.lookahead_on)
previousDayLow =
request.security(
syminfo.tickerid,
"D",
low[1],
lookahead = barmerge.lookahead_on)
previousDayClose =
request.security(
syminfo.tickerid,
"D",
close[1],
lookahead = barmerge.lookahead_on)
//══════════════════════════════════════════════════════════════════════════════
// 16. EVENT LOGIC
//══════════════════════════════════════════════════════════════════════════════
bullInitiative =
not na(deltaPercent) and
deltaPercent >= initiativeDeltaPercent and
close > open and
buyImbalances > sellImbalances
bearInitiative =
not na(deltaPercent) and
deltaPercent <= -initiativeDeltaPercent and
close < open and
sellImbalances > buyImbalances
bullAbsorption =
not na(deltaPercent) and
deltaPercent <= -absorptionDeltaPercent and
lowerWickRatio >= 0.30 and
bodyRatio <= 0.55 and
sellImbalances >= minimumImbalances and
not na(relativeVolume) and
relativeVolume >= minimumRelativeVolume
bearAbsorption =
not na(deltaPercent) and
deltaPercent >= absorptionDeltaPercent and
upperWickRatio >= 0.30 and
bodyRatio <= 0.55 and
buyImbalances >= minimumImbalances and
not na(relativeVolume) and
relativeVolume >= minimumRelativeVolume
bullExpansion =
not na(deltaPercent) and
deltaPercent >= initiativeDeltaPercent and
bodyRatio >= 0.60 and
not na(relativeVolume) and
relativeVolume >= minimumRelativeVolume
bearExpansion =
not na(deltaPercent) and
deltaPercent <= -initiativeDeltaPercent and
bodyRatio >= 0.60 and
not na(relativeVolume) and
relativeVolume >= minimumRelativeVolume
//══════════════════════════════════════════════════════════════════════════════
// 17. EVENT PRIORITY
//══════════════════════════════════════════════════════════════════════════════
bool bullEvent = false
bool bearEvent = false
string bullEventName = ""
string bearEventName = ""
if bullExpansion
bullEvent := true
bullEventName := "EXPANSION+"
else if bullInitiative
bullEvent := true
bullEventName := "INITIATIVE+"
else if bullAbsorption
bullEvent := true
bullEventName := "ABSORPTION+"
if bearExpansion
bearEvent := true
bearEventName := "EXPANSION-"
else if bearInitiative
bearEvent := true
bearEventName := "INITIATIVE-"
else if bearAbsorption
bearEvent := true
bearEventName := "ABSORPTION-"
//══════════════════════════════════════════════════════════════════════════════
// 18. STRUCTURAL PIVOTS
//══════════════════════════════════════════════════════════════════════════════
float pricePivotLow =
ta.pivotlow(
low,
pivotLeft,
pivotRight)
float pricePivotHigh =
ta.pivothigh(
high,
pivotLeft,
pivotRight)
// Delta value corresponding to the actual pivot bar.
float deltaAtPivotLow =
not na(pricePivotLow) ?
cumulativeDelta[pivotRight] :
na
float deltaAtPivotHigh =
not na(pricePivotHigh) ?
cumulativeDelta[pivotRight] :
na
//══════════════════════════════════════════════════════════════════════════════
// 19. STORED LOW STRUCTURE
//══════════════════════════════════════════════════════════════════════════════
var float previousLowPrice = na
var float previousLowDelta = na
var int previousLowBar = na
var float latestLowPrice = na
var float latestLowDelta = na
var int latestLowBar = na
//══════════════════════════════════════════════════════════════════════════════
// 20. STORED HIGH STRUCTURE
//══════════════════════════════════════════════════════════════════════════════
var float previousHighPrice = na
var float previousHighDelta = na
var int previousHighBar = na
var float latestHighPrice = na
var float latestHighDelta = na
var int latestHighBar = na
//══════════════════════════════════════════════════════════════════════════════
// 21. SIGNAL STATES
//══════════════════════════════════════════════════════════════════════════════
bool bullishDivergence = false
bool bearishDivergence = false
bool bullishContinuation = false
bool bearishContinuation = false
string currentStructureSignal = "NONE"
// Label position is based on ATR measured on the actual pivot bar.
float labelATRLow = not na(atr[pivotRight]) ? atr[pivotRight] * labelATRDistance : 0.0
float labelATRHigh = not na(atr[pivotRight]) ? atr[pivotRight] * labelATRDistance : 0.0
//══════════════════════════════════════════════════════════════════════════════
// 22. LOW STRUCTURE ANALYSIS
//══════════════════════════════════════════════════════════════════════════════
if not na(pricePivotLow)
int currentLowBar =
bar_index - pivotRight
float currentLowPrice =
pricePivotLow
float currentLowDelta =
deltaAtPivotLow
float signalBarDeltaLow =
delta[pivotRight]
float signalAvgDeltaLow =
averageAbsDelta[pivotRight]
float signalStrengthLow =
not na(signalBarDeltaLow) and
not na(signalAvgDeltaLow) and
signalAvgDeltaLow > 0 ?
math.abs(signalBarDeltaLow) / signalAvgDeltaLow :
na
float previousSessionStrengthLow =
not na(signalBarDeltaLow) and
not na(previousSessionAvgAbsDelta) and
previousSessionAvgAbsDelta > 0 ?
math.abs(signalBarDeltaLow) / previousSessionAvgAbsDelta :
na
bool hasPreviousLow =
not na(previousLowPrice) and
not na(previousLowDelta)
float requiredPriceMove =
not na(atr[pivotRight]) ?
atr[pivotRight] * minPriceMoveATR :
0.0
float deltaChange =
hasPreviousLow ?
currentLowDelta - previousLowDelta :
na
bool priceLowerLow =
hasPreviousLow and
currentLowPrice < previousLowPrice
bool priceHigherLow =
hasPreviousLow and
currentLowPrice > previousLowPrice
bool deltaHigherLow =
hasPreviousLow and
currentLowDelta > previousLowDelta
bool deltaLowerLow =
hasPreviousLow and
currentLowDelta < previousLowDelta
bool meaningfulPriceMove =
hasPreviousLow and
math.abs(currentLowPrice - previousLowPrice) >= requiredPriceMove
bool meaningfulDeltaMove =
hasPreviousLow and
math.abs(deltaChange) >=
math.abs(previousLowDelta) *
minDeltaMovePercent / 100.0
bullishDivergence :=
showStructure and
priceLowerLow and
deltaHigherLow and
meaningfulPriceMove and
meaningfulDeltaMove
bullishContinuation :=
enableContinuation and
showStructure and
priceHigherLow and
meaningfulPriceMove and
(
not requireDeltaConfirmation or
(
deltaHigherLow and
meaningfulDeltaMove
)
)
if bullishDivergence
currentStructureSignal := "BULL DIV"
if showDivergenceLines and
not na(previousLowBar)
line.new(
previousLowBar,
previousLowPrice,
currentLowBar,
currentLowPrice,
xloc = xloc.bar_index,
color = color.lime,
width = 2,
force_overlay = true)
// COSMETIC CHANGE: BULL DIV -> BLD
string bullDivLabelText = "BLD"
if showLabelDelta
bullDivLabelText += "\nΔ " + (not na(signalBarDeltaLow) ? str.tostring(signalBarDeltaLow, format.volume) : "N/A")
if showLabelAvgDelta
bullDivLabelText += "\n|Δ| " + (not na(signalAvgDeltaLow) ? str.tostring(signalAvgDeltaLow, format.volume) : "N/A")
string bullDivTooltip = ""
if showLabelDelta
bullDivTooltip += "Signal-bar 5m Δ: " + (not na(signalBarDeltaLow) ? str.tostring(signalBarDeltaLow, format.volume) : "N/A")
if showLabelAvgDelta
bullDivTooltip += (bullDivTooltip != "" ? "\n" : "") + "Session avg |Δ|: " + (not na(signalAvgDeltaLow) ? str.tostring(signalAvgDeltaLow, format.volume) : "N/A")
bullDivTooltip += (bullDivTooltip != "" ? "\n" : "") + "Vs session avg: " + (not na(signalStrengthLow) ? str.tostring(signalStrengthLow, "#.##") + "x" : "N/A")
bullDivTooltip += "\nVs previous session avg: " + (not na(previousSessionStrengthLow) ? str.tostring(previousSessionStrengthLow, "#.##") + "x" : "N/A")
label.new(
currentLowBar,
currentLowPrice - labelATRLow,
bullDivLabelText,
xloc = xloc.bar_index,
style = label.style_label_up,
color = color.lime,
textcolor = color.black,
size = size.small,
tooltip = bullDivTooltip,
force_overlay = true)
else if bullishContinuation
currentStructureSignal := "BULL CONT"
if showContinuationLines and
not na(previousLowBar)
line.new(
previousLowBar,
previousLowPrice,
currentLowBar,
currentLowPrice,
xloc = xloc.bar_index,
color = color.aqua,
width = 2,
style = line.style_dashed,
force_overlay = true)
if showContinuationLabels
// COSMETIC CHANGE: BULL CONT -> BLC
string bullContLabelText = "BLC"
if showLabelDelta
bullContLabelText += "\nΔ " + (not na(signalBarDeltaLow) ? str.tostring(signalBarDeltaLow, format.volume) : "N/A")
if showLabelAvgDelta
bullContLabelText += "\n|Δ| " + (not na(signalAvgDeltaLow) ? str.tostring(signalAvgDeltaLow, format.volume) : "N/A")
string bullContTooltip = ""
if showLabelDelta
bullContTooltip += "Signal-bar 5m Δ: " + (not na(signalBarDeltaLow) ? str.tostring(signalBarDeltaLow, format.volume) : "N/A")
if showLabelAvgDelta
bullContTooltip += (bullContTooltip != "" ? "\n" : "") + "Session avg |Δ|: " + (not na(signalAvgDeltaLow) ? str.tostring(signalAvgDeltaLow, format.volume) : "N/A")
bullContTooltip += (bullContTooltip != "" ? "\n" : "") + "Vs session avg: " + (not na(signalStrengthLow) ? str.tostring(signalStrengthLow, "#.##") + "x" : "N/A")
bullContTooltip += "\nVs previous session avg: " + (not na(previousSessionStrengthLow) ? str.tostring(previousSessionStrengthLow, "#.##") + "x" : "N/A")
label.new(
currentLowBar,
currentLowPrice - labelATRLow,
bullContLabelText,
xloc = xloc.bar_index,
style = label.style_label_up,
color = color.aqua,
textcolor = color.black,
size = size.small,
tooltip = bullContTooltip,
force_overlay = true)
previousLowPrice := currentLowPrice
previousLowDelta := currentLowDelta
previousLowBar := currentLowBar
latestLowPrice := currentLowPrice
latestLowDelta := currentLowDelta
latestLowBar := currentLowBar
//══════════════════════════════════════════════════════════════════════════════
// 23. HIGH STRUCTURE ANALYSIS
//══════════════════════════════════════════════════════════════════════════════
if not na(pricePivotHigh)
int currentHighBar =
bar_index - pivotRight
float currentHighPrice =
pricePivotHigh
float currentHighDelta =
deltaAtPivotHigh
float signalBarDeltaHigh =
delta[pivotRight]
float signalAvgDeltaHigh =
averageAbsDelta[pivotRight]
float signalStrengthHigh =
not na(signalBarDeltaHigh) and
not na(signalAvgDeltaHigh) and
signalAvgDeltaHigh > 0 ?
math.abs(signalBarDeltaHigh) / signalAvgDeltaHigh :
na
float previousSessionStrengthHigh =
not na(signalBarDeltaHigh) and
not na(previousSessionAvgAbsDelta) and
previousSessionAvgAbsDelta > 0 ?
math.abs(signalBarDeltaHigh) / previousSessionAvgAbsDelta :
na
bool hasPreviousHigh =
not na(previousHighPrice) and
not na(previousHighDelta)
float requiredPriceMove =
not na(atr[pivotRight]) ?
atr[pivotRight] * minPriceMoveATR :
0.0
float deltaChange =
hasPreviousHigh ?
currentHighDelta - previousHighDelta :
na
bool priceHigherHigh =
hasPreviousHigh and
currentHighPrice > previousHighPrice
bool priceLowerHigh =
hasPreviousHigh and
currentHighPrice < previousHighPrice
bool deltaLowerHigh =
hasPreviousHigh and
currentHighDelta < previousHighDelta
bool deltaHigherHigh =
hasPreviousHigh and
currentHighDelta > previousHighDelta
bool meaningfulPriceMove =
hasPreviousHigh and
math.abs(currentHighPrice - previousHighPrice) >= requiredPriceMove
bool meaningfulDeltaMove =
hasPreviousHigh and
math.abs(deltaChange) >=
math.abs(previousHighDelta) *
minDeltaMovePercent / 100.0
bearishDivergence :=
showStructure and
priceHigherHigh and
deltaLowerHigh and
meaningfulPriceMove and
meaningfulDeltaMove
bearishContinuation :=
enableContinuation and
showStructure and
priceLowerHigh and
meaningfulPriceMove and
(
not requireDeltaConfirmation or
(
deltaLowerHigh and
meaningfulDeltaMove
)
)
if bearishDivergence
currentStructureSignal := "BEAR DIV"
if showDivergenceLines and
not na(previousHighBar)
line.new(
previousHighBar,
previousHighPrice,
currentHighBar,
currentHighPrice,
xloc = xloc.bar_index,
color = color.orange,
width = 2,
force_overlay = true)
// COSMETIC CHANGE: BEAR DIV -> BRD
string bearDivLabelText = "BRD"
if showLabelDelta
bearDivLabelText += "\nΔ " + (not na(signalBarDeltaHigh) ? str.tostring(signalBarDeltaHigh, format.volume) : "N/A")
if showLabelAvgDelta
bearDivLabelText += "\n|Δ| " + (not na(signalAvgDeltaHigh) ? str.tostring(signalAvgDeltaHigh, format.volume) : "N/A")
string bearDivTooltip = ""
if showLabelDelta
bearDivTooltip += "Signal-bar 5m Δ: " + (not na(signalBarDeltaHigh) ? str.tostring(signalBarDeltaHigh, format.volume) : "N/A")
if showLabelAvgDelta
bearDivTooltip += (bearDivTooltip != "" ? "\n" : "") + "Session avg |Δ|: " + (not na(signalAvgDeltaHigh) ? str.tostring(signalAvgDeltaHigh, format.volume) : "N/A")
bearDivTooltip += (bearDivTooltip != "" ? "\n" : "") + "Vs session avg: " + (not na(signalStrengthHigh) ? str.tostring(signalStrengthHigh, "#.##") + "x" : "N/A")
bearDivTooltip += "\nVs previous session avg: " + (not na(previousSessionStrengthHigh) ? str.tostring(previousSessionStrengthHigh, "#.##") + "x" : "N/A")
label.new(
currentHighBar,
currentHighPrice + labelATRHigh,
bearDivLabelText,
xloc = xloc.bar_index,
style = label.style_label_down,
color = color.orange,
textcolor = color.black,
size = size.small,
tooltip = bearDivTooltip,
force_overlay = true)
else if bearishContinuation
currentStructureSignal := "BEAR CONT"
if showContinuationLines and
not na(previousHighBar)
line.new(
previousHighBar,
previousHighPrice,
currentHighBar,
currentHighPrice,
xloc = xloc.bar_index,
color = color.yellow,
width = 2,
style = line.style_dashed,
force_overlay = true)
if showContinuationLabels
// COSMETIC CHANGE: BEAR CONT -> BRC
string bearContLabelText = "BRC"
if showLabelDelta
bearContLabelText += "\nΔ " + (not na(signalBarDeltaHigh) ? str.tostring(signalBarDeltaHigh, format.volume) : "N/A")
if showLabelAvgDelta
bearContLabelText += "\n|Δ| " + (not na(signalAvgDeltaHigh) ? str.tostring(signalAvgDeltaHigh, format.volume) : "N/A")
string bearContTooltip = ""
if showLabelDelta
bearContTooltip += "Signal-bar 5m Δ: " + (not na(signalBarDeltaHigh) ? str.tostring(signalBarDeltaHigh, format.volume) : "N/A")
if showLabelAvgDelta
bearContTooltip += (bearContTooltip != "" ? "\n" : "") + "Session avg |Δ|: " + (not na(signalAvgDeltaHigh) ? str.tostring(signalAvgDeltaHigh, format.volume) : "N/A")
bearContTooltip += (bearContTooltip != "" ? "\n" : "") + "Vs session avg: " + (not na(signalStrengthHigh) ? str.tostring(signalStrengthHigh, "#.##") + "x" : "N/A")
bearContTooltip += "\nVs previous session avg: " + (not na(previousSessionStrengthHigh) ? str.tostring(previousSessionStrengthHigh, "#.##") + "x" : "N/A")
label.new(
currentHighBar,
currentHighPrice + labelATRHigh,
bearContLabelText,
xloc = xloc.bar_index,
style = label.style_label_down,
color = color.yellow,
textcolor = color.black,
size = size.small,
tooltip = bearContTooltip,
force_overlay = true)
previousHighPrice := currentHighPrice
previousHighDelta := currentHighDelta
previousHighBar := currentHighBar
latestHighPrice := currentHighPrice
latestHighDelta := currentHighDelta
latestHighBar := currentHighBar
//══════════════════════════════════════════════════════════════════════════════
// 29. DISJOINT SESSION LOCATION LEVELS
//══════════════════════════════════════════════════════════════════════════════
// Break the plot on the first RTH bar of every session. This explicit na gap
// prevents TradingView from joining the prior session endpoint to the new
// session level when the chart contains no overnight bars.
plot(
showLocationLevels and showPreviousDayLevels and inRTH and not newRTH ?
previousDayHigh : na,
title = "PDH",
color = color.new(color.red, 15),
linewidth = 2,
style = plot.style_linebr,
force_overlay = true)
plot(
showLocationLevels and showPreviousDayLevels and inRTH and not newRTH ?
previousDayLow : na,
title = "PDL",
color = color.new(color.lime, 15),
linewidth = 2,
style = plot.style_linebr,
force_overlay = true)
plot(
showLocationLevels and showPreviousDayLevels and inRTH and not newRTH ?
previousDayClose : na,
title = "PDC",
color = color.new(color.gray, 25),
linewidth = 2,
style = plot.style_linebr,
force_overlay = true)
plot(
showLocationLevels and inRTH and not newRTH ? rthOpen : na,
title = "RTH Open",
color = color.new(color.aqua, 15),
linewidth = 2,
style = plot.style_linebr,
force_overlay = true)
plot(
showLocationLevels and showVWAP and inRTH and not newRTH ? sessionVWAP : na,
title = "RTH VWAP",
color = color.yellow,
linewidth = 2,
style = plot.style_linebr,
force_overlay = true)
plot(
showLocationLevels and showOpeningRange and inRTH and not newRTH ?
openingRangeHigh : na,
title = "Opening Range High",
color = color.new(color.blue, 20),
linewidth = 2,
style = plot.style_linebr,
force_overlay = true)
plot(
showLocationLevels and showOpeningRange and inRTH and not newRTH ?
openingRangeLow : na,
title = "Opening Range Low",
color = color.new(color.blue, 20),
linewidth = 2,
style = plot.style_linebr,
force_overlay = true)
//══════════════════════════════════════════════════════════════════════════════
// 31. STRUCTURAL SIGNAL ALERTS
//══════════════════════════════════════════════════════════════════════════════
anyStructuralSignal = bullishDivergence or bullishContinuation or bearishDivergence or bearishContinuation
alertcondition(
anyStructuralSignal,
title = "Any Structural Signal",
message = "FPD: A structural signal (Bull Divergence, Bull Continuation, Bear Divergence, or Bear Continuation) has triggered on {{ticker}} ({{interval}}). Signal confirmed at {{close}}."
)