Stochastic RSI + Heikin-Ashi

CoffeeshopCrypto · study · 40 行 · 点赞 1,741 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CoffeeshopCrypto
 
//@version=5
 
indicator("Stochastic RSI + Heikin-Ashi", shorttitle="Stocashi", overlay=false)
 
// Calculate the Stochastic RSI
src = input(close, title="Source")
smoothK = input.int(3, 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(d, math.min(ha_open, ha_close))
 
// Plot the Heikin-Ashi Stochastic RSI
//var color color_up   = #07cc00
//var color color_down = #b60c0c
 
up_color = color.from_gradient(k, -50, 0, color.rgb(255, 82, 82), color.rgb(4, 161, 10))
down_color = color.from_gradient(k, 0, 50, color.rgb(255, 82, 82), color.rgb(4, 161, 10))
bar_color = ha_close >= ha_open ? up_color : down_color
 
 
 
// 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)

← 返回列表