Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © Maurizio-Ciullo
- // https://www.tradingcode.net/tradingview/session-highest-high/
- // USED FOR INTRA DAY ONLY, NOT FOR DAILY OR MAJOUR //
- //@version=5
- indicator(title="Indicatore Session_Max high/low/open/close", overlay=true)
- // SessionHigh() returns the highest price during the specified
- // session, optionally corrected for the given time zone.
- // Returns 'na' when the session hasn't started or isn't on the chart.
- SessionHigh(sessionTime, sessionTimeZone=syminfo.timezone) =>
- insideSession = not na(time(timeframe.period, sessionTime, sessionTimeZone))
- var float sessionHighPrice = na
- if insideSession and not insideSession[1]
- sessionHighPrice := high
- else if insideSession
- sessionHighPrice := math.max(sessionHighPrice, high)
- sessionHighPrice
- // InSession() returns 'true' when the current bar happens inside
- // the specified session, corrected for the given time zone (optional).
- // Returns 'false' when the bar doesn't happen in that time period,
- // or when the chart's time frame is 1 day or higher.
- InSession(sessionTimes, sessionTimeZone=syminfo.timezone) =>
- not na(time(timeframe.period, sessionTimes, sessionTimeZone))
- // Configure session with inputs
- session = input.session("0800-1700", title="Trading Session")
- timeZone = input.string("GMT", title="Time Zone")
- // Get the session high
- sessHigh = SessionHigh(session, timeZone)
- // Show the session high on the chart
- plot(sessHigh, color=color.green, title="Session High")
- // For visual verification, highlight the background of session bars
- bgcolor(InSession(session, timeZone) ? color.new(color.orange, 90) : na)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement