fix: Correct band fill in Sunny_Bands.pine using plot references

This commit is contained in:
Bobby (aider) 2025-02-08 09:48:25 -08:00
parent 072fba4006
commit 95d1692349

View File

@ -21,10 +21,13 @@ lower_band = dma - (atr * atr_multiplier)
bullish = ta.crossover(close, lower_band) bullish = ta.crossover(close, lower_band)
bearish = ta.crossunder(close, upper_band) bearish = ta.crossunder(close, upper_band)
// Plotting with similar colors to Python version // Store plot references for fill
plot(dma, "DMA", color=color.new(#009688, 0), linewidth=2) dma_plot = plot(dma, "DMA", color=color.new(#009688, 0), linewidth=2)
plot(upper_band, "Upper Band", color=color.new(#FF5252, 0), linewidth=2) upper_plot = plot(upper_band, "Upper Band", color=color.new(#FF5252, 0), linewidth=2)
plot(lower_band, "Lower Band", color=color.new(#4CAF50, 0), linewidth=2) lower_plot = plot(lower_band, "Lower Band", color=color.new(#4CAF50, 0), linewidth=2)
// Correct fill using plot references
fill(upper_plot, lower_plot, color.new(#673AB7, 90), "Band Area")
// Signal markers // Signal markers
plotshape(bullish, "Bullish Signal", style=shape.triangleup, plotshape(bullish, "Bullish Signal", style=shape.triangleup,
@ -32,9 +35,6 @@ plotshape(bullish, "Bullish Signal", style=shape.triangleup,
plotshape(bearish, "Bearish Signal", style=shape.triangledown, plotshape(bearish, "Bearish Signal", style=shape.triangledown,
location=location.abovebar, color=color.red, size=size.small) location=location.abovebar, color=color.red, size=size.small)
// Background between bands like Python version
fill(upper_band, lower_band, color.new(#673AB7, 90), title="Band Area")
// Alerts equivalent to get_signals() method // Alerts equivalent to get_signals() method
alertcondition(bullish, "Bullish Signal Detected", alertcondition(bullish, "Bullish Signal Detected",
"Sunny Bands: Bullish crossover of lower band") "Sunny Bands: Bullish crossover of lower band")