Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- There are two approaches.
- 1) Reliable:
- ####
- Time_zone = input(-7, title="Your Timezone (i.e. -4)")
- gmt_phrase = Exchange_time ? syminfo.timezone : "GMT"+(Time_zone>0 ? "+" : "") + tostring(Time_zone)
- tz_time = timestamp(syminfo.timezone, year, month, dayofmonth, hour, minute)
- chosen_time = timestamp(gmt_phrase, year, month, dayofmonth, hour, minute)
- tz_diff = (tz_time-chosen_time)/(3600000)//i.e. 1
- Time_zone_final=tz_diff //cant be used in "time" function
- t1 = timestamp(gmt_phrase, year, month, dayofmonth, HHMM_start/100-tz_diff, HHMM_start%100)
- t2 = timestamp(gmt_phrase, year, month, dayofmonth + (HHMM_start<HHMM_end?0:1), HHMM_end/100-tz_diff, HHMM_end%100)
- times_inside = timeframe.isdwm or chosen_time >= t1 and chosen_time<t2
- 2) Exchange-time dependant:
- ####
- Time_zone_diff= input(-2, title="Your Timezone difference from exchange timezone")
- WorkingDays = input(1234567)
- HHMM_start_final = (HHMM_start- Time_zone_diff*100 + 2400) % 2400
- HHMM_end_final = (HHMM_end - Time_zone_diff*100 + 2400) % 2400
- Time_session= (HHMM_start_final<1000 ? "0" : "" ) + tostring(HHMM_start_final)+"-"+ (HHMM_end_final<1000 ? "0" : "" ) + tostring(HHMM_end_final)
- times_inside= timeframe.isdwm or not na(time(timeframe.period, Time_session+":"+tostring(WorkingDays)))
- ##########
- show_time_limits = input(true, title="For testing purposes, visually see marks when within allowed times")
- plotchar(show_time_limits and times_inside ? highest(high,50) : na , title="within allowed times", color=color.green, char="", location=location.absolute, text="ā\nā°")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement