admin管理员组

文章数量:1126342

My strategy was made for the Daily Timeframe but the alert is triggered at 3:00pm instead of been triggered tomorrow when the market is open how can I fix my script

Strategy

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 and chaikin_osc > 0 

sell_condition = barstate.isconfirmed and (chaikin_osc < 0)


if buy_condition

    strategy.entry("Long", strategy.long, qty=equity, comment="Long")

    alert(alert_message, alert.freq_once_per_bar_close)

if sell_condition

    strategy.close("Long", comment="Cerrar Long")

    alert(alert_message, alert.freq_once_per_bar_close)

I need to trigger the alerts for buy_condition and sell_condition when the market is open

My strategy was made for the Daily Timeframe but the alert is triggered at 3:00pm instead of been triggered tomorrow when the market is open how can I fix my script

Strategy

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 and chaikin_osc > 0 

sell_condition = barstate.isconfirmed and (chaikin_osc < 0)


if buy_condition

    strategy.entry("Long", strategy.long, qty=equity, comment="Long")

    alert(alert_message, alert.freq_once_per_bar_close)

if sell_condition

    strategy.close("Long", comment="Cerrar Long")

    alert(alert_message, alert.freq_once_per_bar_close)

I need to trigger the alerts for buy_condition and sell_condition when the market is open

Share Improve this question edited 2 days ago Gu5tavo71 1,1611 gold badge6 silver badges17 bronze badges asked Jan 8 at 21:54 Jorge Ter VeenJorge Ter Veen 11 bronze badge New contributor Jorge Ter Veen is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

barstate.isconfirmed Returns true in the last (closing) update of the current bar.

Try with session.ismarket

buy_condition = session.ismarket and chaikin_osc > 0 

sell_condition = session.ismarket and (chaikin_osc < 0)

本文标签: pine scriptPinescript Strategy Alert Triggered when market closedStack Overflow