警报条件/连续信号简写



我有这个代码,如果条形图在EMA上方/下方会改变颜色。我让警报生效了。然而,它提醒我每一支蜡烛。

如果有人能帮助我实现警报只运行一次,我将不胜感激。

这是代码,请随时发布你的更高级的版本。

study(title="Bar Color", shorttitle="BColor", overlay=true)
src = close, len = input(20, minval=1, title="EMA")
p1= ema(src,len)
plot(p1)
ut   = close > p1 and close[1] > p1 
dt = close < p1 and close[1] < p1
uc = close > close[1] or high > high[1] and low > low[1]
dc = close < close[1] or high < high[1] and low < low[1]
barColour = (ut and uc) ? #53B987 :
(ut and dc) ? #53B987 :
(dt and dc) ? #EB4D5C :
(dt and uc) ? #EB4D5C :
na
barcolor(color=barColour)
alertcondition(ut, title="Buy Alert")
alertcondition(dt, title="Sell Alert")

谢谢

您可以比较更改警报条件以检查当前栏信号和前一个栏信号。如果之前的柱状信号为假,当前柱状信号为真,则发送警报。在下面的示例

alertcondition(ut and not ut[1], title="Buy Alert")
alertcondition(dt and not dt[1], title="Sell Alert")

最新更新