0

I want to change the candlestick chart color based on the SuperTrend indicator. I did but there is a problem. The candlestick colors change only if I put my mouse on the SuperTrend line. I want these colors to stay all the time. Here are my codes.

//Supertrend
atrPeriod = 10
factor = 3
[supertrend, direction] = ta.supertrend(factor, atrPeriod)

//Line Plots
LineColorUp = direction < 0 ? color.green : na
SuperTrendUpPlot = plot(supertrend, color = LineColorUp, linewidth = 2, title = "SuperTrendUpPlot")

LineColorDown = direction >= 0 ? color.red : na 
SuperTrendDownPlot = plot(supertrend, color = LineColorDown, linewidth = 2, title = "SuperTrendDownPlot")

//fill
bodyMiddle = plot((open + close) / 2, display=display.none)

fillColor = direction < 0 ? color.green : color.red
fill(bodyMiddle ,SuperTrendUpPlot, color.new(fillColor, 90), fillgaps = false)

//Candle Color
candleColor = direction < 0 ? color.rgb(0, 255, 8) : color.rgb(255, 0, 0)
plotcandle(open, high, low, close, color = candleColor)

I tried to get help from ChatGPT so 0 result :(

1 Answers1

0

It is not a code issue here. You just need to use the visual order to bring the indicator to the front.

visual order

smashapalooza
  • 932
  • 2
  • 2
  • 12