如何指定一个类型的操作以触发警报?
我想在我的脚本中集成警报,但我认为无法选择警报触发的操作(即在应用程序上通知、在弹出窗口上显示、发送邮件等)
//@version=5
strategy("test 3", overlay=true, max_labels_count=500, calc_on_every_tick=true, initial_capital=500, default_qty_value = 500, currency='USD', process_orders_on_close=true, commission_type='percent', commission_value=0.075, default_qty_type=strategy.cash, calc_on_order_fills=true)
// retrieve Heikin Ashi values
haHandle=ticker.heikinashi(syminfo.tickerid)
haOpen=request.security(haHandle,timeframe.period,open)
haClose=request.security(haHandle,timeframe.period,close)
haDeltaAbs=haClose-haClose[1]
haDeltaRel=haDeltaAbs/haClose[1]*100
// Trade Entry
haEntryCondition=haDeltaRel>0 and haDeltaRel[1]<0
strategy.entry("trade", strategy.long, when = haEntryCondition)
// Trade Exit
haThreshold = -0.5
haExitCondition=haDeltaRel<haThreshold
strategy.close("trade", when = haExitCondition)
// Alerts
if(haEntryCondition)
alert("ENTRY", freq=alert.freq_all)
if(haExitCondition)
alert("EXIT", freq=alert.freq_all)
I would like to integrate alerts in my script, but I see no possibility to choose for the action triggered by the alerts (i.e, notify on the app, show on the popup, sending a mail etc.)
//@version=5
strategy("test 3", overlay=true, max_labels_count=500, calc_on_every_tick=true, initial_capital=500, default_qty_value = 500, currency='USD', process_orders_on_close=true, commission_type='percent', commission_value=0.075, default_qty_type=strategy.cash, calc_on_order_fills=true)
// retrieve Heikin Ashi values
haHandle=ticker.heikinashi(syminfo.tickerid)
haOpen=request.security(haHandle,timeframe.period,open)
haClose=request.security(haHandle,timeframe.period,close)
haDeltaAbs=haClose-haClose[1]
haDeltaRel=haDeltaAbs/haClose[1]*100
// Trade Entry
haEntryCondition=haDeltaRel>0 and haDeltaRel[1]<0
strategy.entry("trade", strategy.long, when = haEntryCondition)
// Trade Exit
haThreshold = -0.5
haExitCondition=haDeltaRel<haThreshold
strategy.close("trade", when = haExitCondition)
// Alerts
if(haEntryCondition)
alert("ENTRY", freq=alert.freq_all)
if(haExitCondition)
alert("EXIT", freq=alert.freq_all)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法以编程方式执行此操作。
如果您想对不同的警报采取不同的操作,可以使用
alertcondition()
并命名警报。然后,您可以在创建警报时从下拉菜单中单独选择警报及其操作。You cannot do that programmatically.
If you want to have different actions for different alerts, you can use
alertcondition()
and name an alert. Then you can individually select an alert from the drop-down menu and its action while creating an alert.