Advertisement
retesere20

tradingview hhmm-start-end inside

Oct 2nd, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. There are two approaches.
  2.  
  3.  
  4.  
  5. 1) Reliable:
  6. ####
  7. Time_zone = input(-7, title="Your Timezone (i.e. -4)")
  8. gmt_phrase = Exchange_time ? syminfo.timezone : "GMT"+(Time_zone>0 ? "+" : "") + tostring(Time_zone)
  9. tz_time = timestamp(syminfo.timezone, year, month, dayofmonth, hour, minute)
  10. chosen_time = timestamp(gmt_phrase, year, month, dayofmonth, hour, minute)
  11. tz_diff = (tz_time-chosen_time)/(3600000)//i.e. 1
  12. Time_zone_final=tz_diff //cant be used in "time" function
  13. t1 = timestamp(gmt_phrase, year, month, dayofmonth, HHMM_start/100-tz_diff, HHMM_start%100)
  14. t2 = timestamp(gmt_phrase, year, month, dayofmonth + (HHMM_start<HHMM_end?0:1), HHMM_end/100-tz_diff, HHMM_end%100)
  15. times_inside = timeframe.isdwm or chosen_time >= t1 and chosen_time<t2
  16.  
  17.  
  18.  
  19. 2) Exchange-time dependant:
  20. ####
  21. Time_zone_diff= input(-2, title="Your Timezone difference from exchange timezone")
  22. WorkingDays = input(1234567)
  23. HHMM_start_final = (HHMM_start- Time_zone_diff*100 + 2400) % 2400
  24. HHMM_end_final = (HHMM_end - Time_zone_diff*100 + 2400) % 2400
  25. Time_session= (HHMM_start_final<1000 ? "0" : "" ) + tostring(HHMM_start_final)+"-"+ (HHMM_end_final<1000 ? "0" : "" ) + tostring(HHMM_end_final)
  26. times_inside= timeframe.isdwm or not na(time(timeframe.period, Time_session+":"+tostring(WorkingDays)))
  27.  
  28.  
  29. ##########
  30.  
  31. show_time_limits = input(true, title="For testing purposes, visually see marks when within allowed times")
  32. 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