Labels: improve readability with high-contrast backgrounds (lime+black for next bull, maroon+white for bear) and adjust flip value label

This commit is contained in:
mindesbunister
2025-10-17 11:59:44 +02:00
parent e4f11d252d
commit 01147e373a

View File

@@ -360,14 +360,16 @@ flipLevel := (flipUp or flipDn) ? supertrend : nz(flipLevel[1])
flipLineColor = flipLineAutoColor ? (trend == 1 ? color.new(color.green, 0) : color.new(color.red, 0)) : flipLineCustomCol
plot(showFlipLevelLine ? flipLevel : na, title="Flip Level", color=flipLineColor, linewidth=2, trackprice=true)
// Optional always-visible value label at current bar
// Optional always-visible value label at current bar (high-contrast)
var label flipValLbl = na
if showFlipLevelValue and not na(flipLevel)
if not na(flipValLbl)
label.delete(flipValLbl)
flipLblCol = flipLineAutoColor ? (trend == 1 ? color.new(color.green, 0) : color.new(color.red, 0)) : flipLineCustomCol
// Use darker red for bear to maximize contrast; green stays readable with white text
flipLblBg = flipLineAutoColor ? (trend == 1 ? color.new(color.green, 0) : color.new(color.maroon, 0)) : flipLineCustomCol
flipLblTxt = color.white
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)
style=label.style_label_left, color=flipLblBg, textcolor=flipLblTxt, yloc=yloc.price, size=size.tiny)
// Next flip preview levels (dynamic thresholds)
nextBullLevel = tsl + aBufferATR * atr // price needed to start bull flip counting
@@ -382,20 +384,22 @@ 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
// Optional live value labels for next flip thresholds (high-contrast)
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)
// Bright lime background with black text for readability
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)
style=label.style_label_left, color=color.new(color.lime, 0), textcolor=color.black, yloc=yloc.price, size=size.tiny)
if showNextBearFlip and nextBearActive and not na(nextBearLevel)
if not na(nextBearLbl)
label.delete(nextBearLbl)
// Darker red background for contrast
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)
style=label.style_label_left, color=color.new(color.maroon, 0), 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)