Reputation: 639
I am trying to generate an alert on the opening bar of the day with the previous closing value.
So my code is something like:
lastPrice = barstate.isrealtime ? close[1] : close
message = "My beautiful alert message of previous close price: " + str.tostring(lastPrice)
if (barstate.isfirst)
alert(message, alert.freq_once_per_bar)
I am in Daily chart.
However none of the alert is generated in 9:15 AM when the Indian market opens up.
So my expectation is:
At the very first minute of the market open (say 9:15 AM), I want the alert message to be fired up.
I put the alert message setting something like this:
Upvotes: 0
Views: 2376
Reputation: 21342
barstate.isfirst
will return true
only for the very first bar on your chart.
If you want to detect the first bar of the day, use something like below:
is_first_bar = ta.change(time("D"))
Upvotes: 2