如何指定一个类型的操作以触发警报?

发布于 2025-01-17 13:04:40 字数 1034 浏览 1 评论 0原文

我想在我的脚本中集成警报,但我认为无法选择警报触发的操作(即在应用程序上通知、在弹出窗口上显示、发送邮件等)

//@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千里故人稀 2025-01-24 13:04:40

您无法以编程方式执行此操作。

如果您想对不同的警报采取不同的操作,可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文