我的策略是针对每日时间范围制定的,但警报在下午 3:00 触发,而不是明天开市时触发,我该如何修复我的脚本
策略
chaikin_length_short = input(10, "Chaikin Fast Length", group="Chaikin Osc")
chaikin_length_long = input(20, "Chaikin Slow Length", group="Chaikin Osc")
chaikin_osc = ta.ema(ta.accdist, chaikin_length_short) - ta.ema(ta.accdist, chaikin_length_long)
buy_condition = barstate.isconfirmed 且 chaikin_osc > 0
sell_condition = barstate.isconfirmed 和 (chaikin_osc < 0)
如果购买_条件
strategy.entry("Long", strategy.long, qty=equity, comment="Long")
alert(alert_message, alert.freq_once_per_bar_close)
如果卖出_条件
strategy.close("Long", comment="Cerrar Long")
alert(alert_message, alert.freq_once_per_bar_close)
我需要在开市时触发 buy_condition 和 sell_condition 的警报
barstate.isconfirmed
在当前柱的最后(收盘)更新中返回 true。
尝试使用 session.ismarket
buy_condition = session.ismarket and chaikin_osc > 0
sell_condition = session.ismarket and (chaikin_osc < 0)