\n","author":{"@type":"Person","name":"e2e4"},"upvoteCount":2}}}
Reputation: 118289
I would like to label every bar starting from number 1 after market opens. So here market opens 9-15 AM IST, and for example selected timeframe is 3 mins. So I would like to label the first bar as 1, then second bar as 2.. so on until the market hour ends which is 3-30 PM IST.
I looked at this and this. But for me I want to restart the bar numbering again from next opening, so it is not helping me. Can anyone offer some ideas how can I proceed?
Upvotes: 0
Views: 3251
Reputation: 3828
You can declare the session using the input.session()
+ time()
functions, note that you can also specify a correct timezone using the IANA time zone format.
myCount varialbe will reset at the end of the session, otherwise count every bar in:
//@version=5
indicator("session bar counter", overlay = true, max_labels_count = 500)
inputSession = input.session("0915-1530:1234567", "Session")
inTimeRange = na(time(timeframe.period, inputSession, 'Asia/Calcutta')) == false
myCount = int(na)
myCount := inTimeRange ? nz(myCount[1]) + 1 : 0
if inTimeRange
label.new(bar_index, high, str.tostring(myCount), color = color(na), textcolor = color.white)
Upvotes: 2