Pine脚本检查条件



我有一个脚本,根据简单的趋势为背景上色。我想在下降趋势结束后添加一个警报,但我不确定如何编写它

startDown = (fiveEMA < fiveEMA[1] and fiveEMA[1]<fiveEMA[2]and fiveEMA[2]<fiveEMA[3])
startUp = (fiveEMA > fiveEMA[1] and fiveEMA[1]>fiveEMA[2] and fiveEMA[2]>fiveEMA[3])
bgcolor(color=startUp ? color.green : startDown ? color.gray : na)

我已经尝试过barssince,但无法获得语法正确

任何帮助都是非常感谢的

像这样?

if barssince(startDown) == 1
alert("Start of uptrend", alert.freq_once_per_bar_close)
if barssince(startUp) == 1
alert("Start of downtrend", alert.freq_once_per_bar_close)

像这样的吗?

if barssince(startDown) == 1
alert("End of downtrend", alert.freq_once_per_bar_close)
if barssince(startUp) == 1
alert("End of uptrend", alert.freq_once_per_bar_close)

最新更新