Requirement: I am working on a pine strategy where the strategy need to avoid taking any new trades during multiple time range. And this restriction should be applicable only for today/current_tradingday.
E.g. I have taken 3 input.sessions() as in the image:
Issue: The input.session() time are in chart time in local timezone i.e. GMT+5.30. And when strategy executes it doesnt match with exchange time. Referred some online links like https://www.tradingview.com/pine-script-docs/en/v4/concepts/Time.html#id6 but still facing problem converting local time range into exchange time range.
For example to avoid taking any new trades during local 05:00PM to 07:00PM (GMT+5.30) then I have to give input.session("1700-1900") and the strategy shouldn't take any new trades during this time in exchange timezone. And this condition should be valid only for today current_tradingday.
That should do it. In your input you're defining the time you are allowed to trade (in exchange timezone). If your open session ends at some point, then you have to make several session inputs and combine them in your conditional statement before you would place an order.
But the point is, you check the current time measured in the exchange timezone on each bar. If you are within your defined session, the time()
will return you the current UNIX bar time, if you are out of session NaN
session = input.session("1900-1700", "Can place orders")
tz = time(timeframe.period, session, syminfo.timezone)
if tz // and your conditions
label.new(bar_index, 1, "You can place your orders here according to exchange timezone")