首页 > 解决方案 > 带有颜色变化松树脚本的警报

问题描述

我想在交易视图上发送带有颜色变化的警报。这是一个名为 Trix 的指标。但没有警报选项。我尝试添加警报条件但不起作用。

study(title="TRIX (Custom)", shorttitle="TRIX (Custom)")
length = input(6, minval=1)
out = 10000* change(ema(ema(ema(log(close), length), length), length))

upColour    = #33CC33
downColour  = #FF5555
hline(0, title="Zero")
plot(out, color = out[1] > out ? downColour : upColour)

*alertcondition(upColour, title="Buy", message="green buy")
alertcondition(downColour, title="Sell", message="red sell")*

标签: pine-script

解决方案


尝试这样做

alertcondition(out[1] <= out , title="Buy",  message="green buy")
alertcondition(out[1] >  out , title="Sell", message="red sell")

根据评论添加了一个选项

alertcondition(out[2] >  out[1] and out[1] <= out , title="Buy",  message="green buy")
alertcondition(out[2] <= out[1] and out[1] >  out , title="Sell", message="red sell")

推荐阅读