【发布时间】:2021-12-03 02:02:55
【问题描述】:
如果变量barup 为真,我希望它绘制一个系列;如果变量bardown 为真,我希望它绘制另一个系列值。
我当前的代码产生错误:不能使用“在本地范围内绘图”。
如何更改以下代码,以使指标根据当天的高点或低点显示低点高于 30 日均线或低于 30 日均线的天数。
这是我现在拥有的代码:
indicator("LandryLight")
bardown = high < ta.ema(close,30)
barup = low > ta.ema(close,30)
if barup
plot(series=ta.barssince(barup)*-1, title="Consecutive Bars Down", color=color.red, style=plot.style_histogram, linewidth=2)
if bardown
plot(series=ta.barssince(bardown), title="Consecutive Bars Up", color=color.green, style=plot.style_histogram, linewidth=2)
hline(10,title="Threshold", color=color.white, linestyle=hline.style_dashed, linewidth=1)
【问题讨论】:
标签: if-statement plot conditional-statements pine-script