pine-script - 绘图功能未在 pine 脚本中显示所需的结果
问题描述
我是 pine 脚本的新手。我试图在 pine 脚本中创建 Bar RSI 和 Stochastic,但绘图函数未显示预期结果。
当我取消选中显示 RSI 选项时,RSI 仍然绘制在图表上。谁能帮我解决这个问题
// Inputs
src = input(close, title = "RSI Source")
len = input(defval=9, title = "RSI Length", minval = 2, maxval = 100, type=input.integer)
std_bar = input("Std", title = "RSI Style", options = ["Bar", "Std"])
inner = input("Dynamic", title = "RSI Levels Type", options = ["Dynamic", "Fixed", "NA"])
inner_type = input("Standard Deviation", title = "Calculation Method", options = ["Standard Deviation", "Smooth Moving Average"])
inner_mult = input(1.0, title = "Multiplier", minval = 0.0, maxval = 4.0, step = 0.1)
lengthStoch = input(14, "Stochastic Length", minval=1)
smoothK = input(3, "K", minval=1)
smoothD = input(3, "D", minval=1)
//Show
rl = input(true,title="Show RSI", group="Display Settings")
sl = input(false,title="Show Stoch RSI", group="Display Settings")
//Calculation
norm = if std_bar=="Std"
1
else
avg(src, src[1])
RSI = rsi(src, len)
RSI_ch = if inner != "NA"
if inner_type == "Standard Deviation"
stdev(abs(change(RSI)), len)
else
rma(abs(change(RSI)), len)
//RSI Bars
o = std_bar=="Bar" ? RSI[1] : RSI
h = std_bar=="Bar" ? RSI : RSI
l = std_bar=="Bar" ? RSI[1] : RSI
c = std_bar=="Bar" ? RSI : RSI
//Stochastic
k = sma(stoch(RSI, RSI, RSI, lengthStoch), smoothK)
d = sma(k, smoothD)
//Plot
plotbar(o,h,l,c, title="Bar RSI")
plot(rl and std_bar=="Bar" ? na : RSI, color = color.orange, title = "RSI", linewidth = 2)
plot(sl and k ? k : na, "K", color=#0094FF)
plot(sl and d ? d : na, "D", color=#FF6A00)```
解决方案
您的三元陈述似乎与您想要的相反。尝试:
plot(rl and std_bar=="Bar" ? RSI : na, color = color.orange, title = "RSI", linewidth = 2)
推荐阅读
- python - 在 Win 7 Pro 上升级到最新的 Python
- bash - 引用/保护通过管道传输到 bash 的特殊字符?
- r - 从R中的字符串中提取分布函数的参数
- android - RecyclerView EmptyView 有 RecyclerItem
- python - 如何动态将 Pillow 图像导入 Tkinter
- python-3.x - 压缩 Python 多个 re.sub() 函数
- omnet++ - 在 SUMO 中控制车道变更决策
- haskell - 你如何在haskell中使用带有地图和过滤器的输入
- azure - 如何访问在 Azure 中负载均衡器后面的 VM 中运行的 api
- r - 如果R中的第一个小数为零,如何转换为整数?