Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. // @version=4
  2. // © ZenAndTheArtOfTrading
  3. study("Highest High Within Timezone", overlay=true)
  4.  
  5. // Define time window as an input function
  6. timezone = input(title="Timezone To Highlight", type=input.session, defval="1000-1500")
  7. lookback = input(title="Lookback Period", type=input.integer, defval=10)
  8.  
  9. // Convert input timezone into milisecond time
  10. t = time(timeframe.period, timezone)
  11.  
  12. // Check if current bar is within that milisecond time window
  13. barIsWithinTimezone = na(t) ? false : true
  14.  
  15. // Get the highest high of the past X candles ONLY if the current bar is within the time window
  16. highestHighWithinSession = valuewhen(barIsWithinTimezone, highest(high, lookback), 1)
  17.  
  18. // Get the lowest low of the past X candles ONLY if the current bar is within the time window
  19. lowestLowWithinSession = valuewhen(barIsWithinTimezone, lowest(low, lookback), 1)
  20.  
  21. // Plot highs/lows
  22. plot(highestHighWithinSession, color=color.red)
  23. plot(lowestLowWithinSession, color=color.blue)
  24. bgcolor(barIsWithinTimezone ? color.black : na, transp=90)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement