Flip previews: plot Next Bull/Bear Flip thresholds with optional value labels; uses current tsl ± buffer*ATR and activates opposite to current trend
This commit is contained in:
@@ -54,6 +54,10 @@ showFlipLevelLine = input.bool(true, "Show Flip Level line")
|
||||
flipLineAutoColor = input.bool(true, "Flip line color by trend")
|
||||
flipLineCustomCol = input.color(color.new(color.silver, 0), "Flip line custom color")
|
||||
showFlipLevelValue = input.bool(true, "Show Flip Level value label")
|
||||
// Preview of the next flip thresholds
|
||||
showNextBullFlip = input.bool(true, "Show Next Bull Flip level")
|
||||
showNextBearFlip = input.bool(false, "Show Next Bear Flip level")
|
||||
showNextFlipValue = input.bool(true, "Show Next Flip value label")
|
||||
|
||||
// =============================
|
||||
// Per-timeframe profiles (optional)
|
||||
@@ -365,6 +369,34 @@ if showFlipLevelValue and not na(flipLevel)
|
||||
flipValLbl := label.new(bar_index, flipLevel, text="Flip Level: " + str.tostring(flipLevel, format.mintick),
|
||||
style=label.style_label_left, color=flipLblCol, textcolor=color.white, yloc=yloc.price, size=size.tiny)
|
||||
|
||||
// Next flip preview levels (dynamic thresholds)
|
||||
nextBullLevel = tsl + aBufferATR * atr // price needed to start bull flip counting
|
||||
nextBearLevel = tsl - aBufferATR * atr // price needed to start bear flip counting
|
||||
|
||||
nextBullActive = trend == -1
|
||||
nextBearActive = trend == 1
|
||||
|
||||
nbCol = color.new(color.lime, 0)
|
||||
nsCol = color.new(color.red, 0)
|
||||
|
||||
plot(showNextBullFlip and nextBullActive ? nextBullLevel : na, title="Next Bull Flip Level", color=nbCol, linewidth=2, style=plot.style_linebr, trackprice=true)
|
||||
plot(showNextBearFlip and nextBearActive ? nextBearLevel : na, title="Next Bear Flip Level", color=nsCol, linewidth=2, style=plot.style_linebr, trackprice=true)
|
||||
|
||||
// Optional live value labels for next flip thresholds
|
||||
var label nextBullLbl = na
|
||||
var label nextBearLbl = na
|
||||
if showNextFlipValue
|
||||
if showNextBullFlip and nextBullActive and not na(nextBullLevel)
|
||||
if not na(nextBullLbl)
|
||||
label.delete(nextBullLbl)
|
||||
nextBullLbl := label.new(bar_index, nextBullLevel, text="Next Bull Flip: " + str.tostring(nextBullLevel, format.mintick) + (aConfirmBars > 1 ? " (" + str.tostring(aConfirmBars) + " closes)" : ""),
|
||||
style=label.style_label_left, color=nbCol, textcolor=color.white, yloc=yloc.price, size=size.tiny)
|
||||
if showNextBearFlip and nextBearActive and not na(nextBearLevel)
|
||||
if not na(nextBearLbl)
|
||||
label.delete(nextBearLbl)
|
||||
nextBearLbl := label.new(bar_index, nextBearLevel, text="Next Bear Flip: " + str.tostring(nextBearLevel, format.mintick) + (aConfirmBars > 1 ? " (" + str.tostring(aConfirmBars) + " closes)" : ""),
|
||||
style=label.style_label_left, color=nsCol, textcolor=color.white, yloc=yloc.price, size=size.tiny)
|
||||
|
||||
plot(upTrend, "Up Trend", color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2)
|
||||
plot(downTrend, "Down Trend", color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user