Pine script 警报,真或假,从真变假,从假变真

Pine script 警报,真或假,从真变假,从假变真,pine-script,Pine Script,TradingView脚本代码。当警报从true更改为false和false更改为true时,需要警报 //@version=2 study threshold = input(title="Threshold", type=float, defval=0.0014, step=0.0001) buying = l3_0 > threshold ? true : l3_0 < -threshold ? false : buying[1] hline(0, title="b

TradingView脚本代码。当警报从true更改为false和false更改为true时,需要警报

//@version=2
study

threshold = input(title="Threshold", type=float, defval=0.0014, 
step=0.0001)



buying = l3_0 > threshold ? true : l3_0 < -threshold ? false : buying[1]

hline(0, title="base line")
//bgcolor(l3_0 > 0.0014 ? green : l3_0 < -0.0014 ? red : gray, transp=20)
bgcolor(buying ? green : red, transp=20)
plot(l3_0, color=silver, style=area, transp=50)
plot(l3_0, color=aqua, title="prediction")

//longCondition = buying
//if (longCondition)
//    strategy.entry("Long", strategy.long)

//shortCondition = buying != true
//if (shortCondition)
//    strategy.entry("Short", strategy.short)
/@version=2
学习
阈值=输入(title=“阈值”,type=float,deffal=0.0014,
阶跃=0.0001)
购买=l3\u 0>阈值?正确:l3_0<-阈值?错误:购买[1]
hline(0,title=“基线”)
//bgcolor(l3_0>0.0014?绿色:l3_0<-0.0014?红色:灰色,传输=20)
bgcolor(购买?绿色:红色,运输=20)
绘图(l3_0,颜色=银色,样式=面积,传输=50)
绘图(l3_0,颜色=浅绿色,title=“预测”)
//长期条件=购买
//如果(长期条件)
//strategy.entry(“Long”,strategy.Long)
//短条件=购买!=真的
//if(短条件)
//strategy.entry(“Short”,strategy.Short)
把它改成了一项研究。作为一种策略,它发出警报并在图表上标出方向。将其更改为研究,但警报只应在更改时发出。在我的书房里,它提醒着每一支蜡烛,而不是换钱。我尝试的任何方法都只会在每支蜡烛上显示长或短。

您可以使用该函数检查变量是否已更改

//@version=3
study("Custom alert condition", overlay=true)
my_variable = close > open

alertcondition(change(my_variable), title='Triggers when close is above the open or vice versa', message='Candle color changed!')
// this is here because a study chart requires at least one plot, bgcolor or barcolor call
// setting the bar color to na (i.e. N/A) does nothing
barcolor(na)
然后,您可以转到右上角的闹钟图标,创建使用此自定义条件的新警报。可以选择每分钟触发一次、每小节触发一次或其他方式


下面是一个测试警报条件,以查看您是否正确创建了警报,将其设置为每分钟触发一次,并应快速触发

//@version=3
study("Testing condition", overlay=true)
alertcondition(close, title='Triggers when close changes', message='Close has changed!')
barcolor(na)

你看到我对你另一个问题的回答了吗?你认为哪一排给了你警告?你的大部分代码都被注释掉了。谢谢你,巴里斯。是的,我确实收到了你的答复。花了几天时间试图添加到我的脚本中,但无法使其工作。我还在学习代码。了解基本知识并能理解部分代码。我试着用黑客破解,但没能成功。你能帮我看看这个吗?收到了很多建议。你好,枪手。代码最初是一种策略。因此,评论被取消了。我把它忘在里面了,因为我认为它可能会有帮助。进入/退出策略是我在研究中所追求的。只有当它从“真”变为“假”或“假”变为“真”时。需要退出买入,进入卖出。