1

when using chart.bg_color or deriving a new color with color.rgb() from a user input input.color() for filling two plots with fill(), the color options disappear in Settings > Style. Is this normal behavior and has a reason to it or is this a bug? I attached a basic sample code with four different color-schemes. Fill 1-3 provoke the bug. For testing reasons I also added Fill 4, to show that the color options re-appear when not using chart.bg_color or color.rgb().

Appreciate your help.

Phil

//@version=5
indicator("Color Settings Bug", overlay=true)

// User input colors for up and down
i_clrup = input.color(color.new(#29ebd0, 0), title="Color Up")
i_clrdn = input.color(color.new(#ec5c74, 0), title="Color Down")

// Two moving averages
ma_fast = ta.sma(close, 10)
ma_slow = ta.sma(close, 50)
ma_trend = ma_fast > ma_slow ? 1 : ma_fast < ma_slow ? -1 : 0 // trend for the fill color logic
top_ma = math.max(ma_fast, ma_slow) // upper ma for the fill color logic
bottom_ma = math.min(ma_fast, ma_slow) // lower ma for the fill color logic

// MA plots
p1 = plot(ma_fast, "MA Fast", display = display.none, editable = true) // editable true, so the colors should appear in the Style-tab in the indicator settings
p2 = plot(ma_slow, "MA Slow", display = display.none, editable = true) // editable true, so the colors should appear in the Style-tab in the indicator settings

// Colors for the fill between the two MAs based on the user input (in a more complex script needed to derive certain colors and color shades from a single user input)
bgclrup = color.rgb(color.r(i_clrup), color.g(i_clrup), color.b(i_clrup), 40)
bgclrdn = color.rgb(color.r(i_clrdn), color.g(i_clrdn), color.b(i_clrdn), 40)

// Fill 1: rgb-color from input color + chart.bg_color --> Breaks color settings in style tab in indicator settings
fill(p1, p2
 , top_value = top_ma
 , bottom_value = bottom_ma
 , top_color = ma_trend == 1 ? color.new(chart.bg_color, 100) : bgclrdn
 , bottom_color = ma_trend == 1 ? bgclrup : color.new(chart.bg_color, 100)
 , title = "Background Gradient"
 , editable = true)

// Fill 2: rgb-color from input color + normal color --> Breaks color settings in style tab in indicator settings
//fill(p1, p2
// , top_value = top_ma
// , bottom_value = bottom_ma
// , top_color = ma_trend == 1 ? color.new(color.green, 100) : bgclrdn
// , bottom_color = ma_trend == 1 ? bgclrup : color.new(color.red, 100)
// , title = "Background Gradient"
// , editable = true) 

// Fill 3: chart.bg_color + normal color --> Breaks color settings in style tab in indicator settings
//fill(p1, p2
// , top_value = top_ma
// , bottom_value = bottom_ma
// , top_color = ma_trend == 1 ? color.new(chart.bg_color, 100) : color.red
// , bottom_color = ma_trend == 1 ? color.green : color.new(chart.bg_color, 100)
// , title = "Background Gradient"
// , editable = true)

// Fill 4 - No derived colors - Works
//fill(p1, p2
// , top_value = top_ma
// , bottom_value = bottom_ma
// , top_color = ma_trend == 1 ? color.new(color.green, 100) : color.red
// , bottom_color = ma_trend == 1 ? color.green : color.new(color.red, 100)
// , title = "Background Gradient"
// , editable = true) 
Phil5590
  • 11
  • 1

1 Answers1

0

If your script has calculated colors, then the color widget in the style tab won't be available.

You can read more details from here.

If your script uses a calculated color, i.e., a color where at least one of its RGBA components can only be known at runtime, then the “Settings/Style” tab will NOT offer users the usual color widgets they can use to modify your plot colors. Plots of the same script not using calculated colors will also be affected.

vitruvius
  • 15,740
  • 3
  • 16
  • 26