I want my Pinescript code to start with UTC-4 (GMT-5) instead of the default UTC. You can see my indicator starts at 17:00 in the images. So 17:00-17:00 is a daily span instead of 00:00-00:00 in UTC-4. Any help with a function I can add that changes what a daily value is would be appreciated.Thank you. I have an image of the chart attached with the code below.
//@version=5
//
indicator(title='CPR, VWAP, EMAs, MASTER - CAM', shorttitle='CPR,VWAP,EMAs, MASTER', overlay=true)
//TIMEZONE
zone = input("GMT-5")
daily_cpr = input.int(title='Number of Daily CPR Back', defval=100, minval=0)
onehr_cpr = input.int(title='Number of 1HR CPR Back', defval=0, minval=0)
fourhr_cpr = input.int(title='Number of 4HR CPR Back', defval=0, minval=0)
eighthr_cpr = input.int(title='Number of 8HR CPR Back', defval=0, minval=0)
weekly_cpr = input.int(title='Number of Weekly CPR Back', defval=0, minval=0)
monthly_cpr = input.int(title='Number of Monthly CPR Back', defval=0, minval=0)
new_bar(res) =>
ta.change(time(res)) != 0
new_period(condition, src) =>
result = 0.0
result := condition ? src : result[1]
result
pivot = (high + low + close) / 3.0
bc = (high + low) / 2.0
tc = pivot - bc + pivot
//Daily Central Pivot Range
dpp = request.security(syminfo.tickerid, 'D', pivot[1], lookahead=barmerge.lookahead_on)
dbc = request.security(syminfo.tickerid, 'D', bc[1], lookahead=barmerge.lookahead_on)
dtc = request.security(syminfo.tickerid, 'D', tc[1], lookahead=barmerge.lookahead_on)
one_day = 1000 * 60 * 60 * 24
new_day = daily_cpr > 0 and timenow - time < one_day * daily_cpr and new_bar('D')
dpp_ = new_period(new_day, dpp)
dtc_ = new_period(new_day, dtc)
dbc_ = new_period(new_day, dbc)
plot(timeframe.isintraday ? dtc_ >= dbc_ ? dtc_ : dbc_ : na, title='Daily TC', style=plot.style_steplinebr, color=color.new(#238859, 0), linewidth=1)
plot(timeframe.isintraday ? dpp_ : na, title='Daily PP', style=plot.style_steplinebr, color=color.new(#238859, 0), linewidth=1)
plot(timeframe.isintraday ? dtc_ >= dbc_ ? dbc_ : dtc_ : na, title='Daily BC', style=plot.style_steplinebr, color=color.new(#238859, 0), linewidth=1)`
I've tried adding the Timezone option and having a drop down timezone option does not change when the indicator starts and stops.
I've attempted utilizing syminfo.timezone as well but couldn't properly add it to the code.
That is because you are using
request.security()
. It will always use exchange's timezone.These are what you pass to and get from the
security()
call.You need to calculate those values yourself.
Below is an example of how you can get the high price of a day with a custom timezone.