UX: add line width and label size inputs; set Flip Level to linebr so it sticks to candles; apply widths to next-flip lines
This commit is contained in:
@@ -54,6 +54,9 @@ 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")
|
||||
flipLineWidth = input.int(3, "Flip line width", minval=1, maxval=6)
|
||||
nextFlipLineWidth = input.int(2, "Next flip line width", minval=1, maxval=6)
|
||||
labelSizeOpt = input.string("small", "Value label size", options=["tiny","small","normal"])
|
||||
// Preview of the next flip thresholds
|
||||
showNextBullFlip = input.bool(true, "Show Next Bull Flip level")
|
||||
showNextBearFlip = input.bool(false, "Show Next Bear Flip level")
|
||||
@@ -358,7 +361,7 @@ downTrend = trend == -1 ? supertrend : na
|
||||
var float flipLevel = na
|
||||
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)
|
||||
plot(showFlipLevelLine ? flipLevel : na, title="Flip Level", color=flipLineColor, linewidth=flipLineWidth, style=plot.style_linebr, trackprice=true)
|
||||
|
||||
// Optional always-visible value label at current bar (high-contrast)
|
||||
var label flipValLbl = na
|
||||
@@ -368,7 +371,8 @@ if showFlipLevelValue and not na(flipLevel)
|
||||
// High-contrast: black text on green (bull), white text on maroon (bear)
|
||||
flipLblBg = flipLineAutoColor ? (trend == 1 ? color.new(color.green, 0) : color.new(color.maroon, 0)) : flipLineCustomCol
|
||||
flipLblTxt = flipLineAutoColor ? (trend == 1 ? color.black : color.white) : color.white
|
||||
flipValLbl := label.new(bar_index, flipLevel, text="Flip Level: " + str.tostring(flipLevel, format.mintick), style=label.style_label_left, color=flipLblBg, textcolor=flipLblTxt, yloc=yloc.price, size=size.tiny)
|
||||
lblSize = labelSizeOpt == "tiny" ? size.tiny : labelSizeOpt == "small" ? size.small : size.normal
|
||||
flipValLbl := label.new(bar_index, flipLevel, text="Flip Level: " + str.tostring(flipLevel, format.mintick), style=label.style_label_left, color=flipLblBg, textcolor=flipLblTxt, yloc=yloc.price, size=lblSize)
|
||||
|
||||
// Next flip preview levels (dynamic thresholds)
|
||||
nextBullLevel = tsl + aBufferATR * atr // price needed to start bull flip counting
|
||||
@@ -380,8 +384,8 @@ 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)
|
||||
plot(showNextBullFlip and nextBullActive ? nextBullLevel : na, title="Next Bull Flip Level", color=nbCol, linewidth=nextFlipLineWidth, style=plot.style_linebr, trackprice=true)
|
||||
plot(showNextBearFlip and nextBearActive ? nextBearLevel : na, title="Next Bear Flip Level", color=nsCol, linewidth=nextFlipLineWidth, style=plot.style_linebr, trackprice=true)
|
||||
|
||||
// Optional live value labels for next flip thresholds (high-contrast)
|
||||
var label nextBullLbl = na
|
||||
@@ -391,12 +395,12 @@ if showNextFlipValue
|
||||
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=color.new(color.lime, 0), textcolor=color.black, yloc=yloc.price, size=size.tiny)
|
||||
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=color.new(color.lime, 0), textcolor=color.black, yloc=yloc.price, size=lblSize)
|
||||
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=color.new(color.maroon, 0), textcolor=color.white, yloc=yloc.price, size=size.tiny)
|
||||
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=color.new(color.maroon, 0), textcolor=color.white, yloc=yloc.price, size=lblSize)
|
||||
|
||||
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