Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- //This is just a fun script to give a different representation to the ever popular Stochastic RSI
- //Even for me over the years the stochastic has been a difficult one to use in trading mearly beause of its choppy look.
- //Since Heikin-Ashi Candles do such a powerful job in smoothing out the look of choppy markets,
- //I decided to test it out on the look of the Stochastic RSI.
- //From an initial visual standpoint it worked out WAY better than I thought but it seemed to need something more.
- //I decided to use the PineScript "Color.From_Gradient" feature to give the Stochastic a more 3 dimentional look, which really brought the "old-school" indicator to life.
- // © CoffeeshopCrypto
- //@version=5
- indicator("Stochastic RSI + Heikin-Ashi", shorttitle="Stocashi", overlay=false)
- // Calculate the Stochastic RSI
- src = input(close, title="Source")
- smoothK = input.int(8, minval=1, title="Stochastic %K Smoothing")
- smoothD = input.int(3, minval=1, title="Stochastic %D Smoothing")
- lengthRSI = input.int(14, minval=1, title="RSI Length")
- rsi1 = ta.rsi(src, lengthRSI)
- lengthStoch = input.int(14, minval=1, title="Stochastic Length")
- k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK) - 50
- d = ta.sma(k, smoothD)
- // Calculate the Stochastic Heikin-Ashi candles
- ha_open = (k[1] + d[1]) / 2
- ha_close = (k + d + d + k) / 4
- ha_high = math.max(k, math.max(ha_open, ha_close))
- ha_low = math.min(k, math.min(ha_close, ha_open))
- // Plot the Heikin-Ashi Stochastic RSI
- down_colorbottom = input.color(#086e05, title="Bullish Move Start")
- down_colortop = input.color(#8dc474, title="Bullish Move End")
- up_color_top = input.color(#af0505, title="Bearish Move Start")
- up_color_bottom = input.color(#e08e8e, title="Bearish Move End")
- gradientColourup = color.from_gradient(k, -50, 50, up_color_bottom, up_color_top)
- //gradientColouruptop = color.from_gradient(k, -50, 30, up_color, down_color)
- gradientColourdn = color.from_gradient(k, -50, 50, down_colorbottom, down_colortop)
- //gradientColourdntop = color.from_gradient(k, -30, 50, up_color, down_color)
- bar_color = ha_close >= ha_open ? gradientColourdn : gradientColourup
- // Use the up and down colors in your script
- //////////////////////////////////////////////
- plotcandle(ha_open, ha_high, ha_low, ha_close,title= "Stochatic Heiken Ashi Gradient", color=bar_color, wickcolor = bar_color)
- mindline = hline(0, color=#d47305a1)
- line80 = hline(30, color=#d6cfc875, linestyle = hline.style_solid)
- linem10 = hline(-30, color=#d6cfc875, linestyle = hline.style_solid)
Advertisement
Add Comment
Please, Sign In to add comment