xmd79

Time Filter

Apr 30th, 2023
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © DaviG
  3.  
  4. //@version=5
  5. indicator("Time Filter", overlay=true)
  6.  
  7. transparency = input.int(title="Time Filter background transparency", defval=80)
  8. gmtSelect = input.string(title="Select Local Time Zone", defval="GMT+2", options=["GMT-7", "GMT-6", "GMT-5", "GMT-4", "GMT-3", "GMT-2", "GMT-1", "GMT", "GMT+1", "GMT+2", "GMT+3","GMT+4","GMT+5","GMT+6","GMT+7","GMT+8","GMT+9","GMT+10","GMT+11","GMT+12","GMT+13"], confirm=true)
  9. // === INPUT TIME RANGE ===
  10. betweenTime = input.session('0600-1700', title = "Time Filter") // '0000-0000' is anytime to enter
  11.  
  12. isTime(_position) => // create function "within window of time"
  13. isTime = na(time(timeframe.period, _position + ':1234567', gmtSelect)) // current time is "within window of time"
  14.  
  15. bgcolor(color = isTime(betweenTime) ? color.new(color.red,transparency) : color.new(color.green,transparency))
  16. //
Advertisement
Add Comment
Please, Sign In to add comment