0

So I am trying to achieve something like this. A clean and nice fill, but using my code I get a very ugly filling like in this image

Here is my code

indicator(title="Stochastic RSI", shorttitle="Stoch RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
smoothK = input.int(3, "K", minval=1)
smoothD = input.int(3, "D", minval=1)
lengthRSI = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
transpSwitch = input.int(40, title="Band Transparency",step=5)
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
a = plot(k, "K", color=#2962FF)
b = plot(d, "D", color=#FF6D00)
h0 = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
h1 = hline(20, "Lower Band", color=#787B86)
hullColor = k > d ? #00ff00 : #ff0000
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")
fill(a, b, title="Band Filler", color=hullColor, transp=transpSwitch)

1 Answers1

0

The only difference I can tell between the plots in the two images is that your goal image has a smoothed plot and yours doesn't.

You can try replacing plot a and b with:

a = plot(ta.sma(k, 2), "K", color=#2962FF)
b = plot(ta.sma(d, 2), "D", color=#FF6D00)

Increasing the integer in the sma function will smooth your plot more and more.

DogeCode
  • 346
  • 2
  • 10