Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // @version=4
- // © ZenAndTheArtOfTrading
- study("Highest High Within Timezone", overlay=true)
- // Define time window as an input function
- timezone = input(title="Timezone To Highlight", type=input.session, defval="1000-1500")
- lookback = input(title="Lookback Period", type=input.integer, defval=10)
- // Convert input timezone into milisecond time
- t = time(timeframe.period, timezone)
- // Check if current bar is within that milisecond time window
- barIsWithinTimezone = na(t) ? false : true
- // Get the highest high of the past X candles ONLY if the current bar is within the time window
- highestHighWithinSession = valuewhen(barIsWithinTimezone, highest(high, lookback), 1)
- // Get the lowest low of the past X candles ONLY if the current bar is within the time window
- lowestLowWithinSession = valuewhen(barIsWithinTimezone, lowest(low, lookback), 1)
- // Plot highs/lows
- plot(highestHighWithinSession, color=color.red)
- plot(lowestLowWithinSession, color=color.blue)
- bgcolor(barIsWithinTimezone ? color.black : na, transp=90)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement