Matboom

Monday range by Matboom

The "Monday Range" Pine Script indicator calculates and displays the lowest and highest prices during a specified trading session, focusing on Mondays. Users can configure the trading session parameters, such as start and end times and time zone. The indicator visually highlights the session range on the chart by plotting the session low and high prices and applying a background color within the session period. The customizable days of the week checkboxes allow users to choose which days the indicator should consider for analysis.

Session Configuration:
session = input.session("0000-0000", title="Trading Session")
timeZone = input.string("UTC", title="Time Zone")
monSession = input.bool(true, title="Mon ", group="Trading Session", inline="d1")
tueSession = input.bool(true, title="Tue ", group="Trading Session", inline="d1")
Users can configure the trading session start and end times and the time zone.
Checkboxes for Monday (monSession) and Tuesday (tueSession) sessions are provided.


SessionLow and SessionHigh Functions:
SessionLow(sessionTime, sessionTimeZone=syminfo.timezone) => ...
SessionHigh(sessionTime, sessionTimeZone=syminfo.timezone) => ...
Custom functions to calculate the lowest (SessionLow) and highest (SessionHigh) prices during a specified trading session.

InSession Function:
InSession(sessionTimes, sessionTimeZone=syminfo.timezone) => ...
Determines if the current bar is inside the specified trading session.

Days of Week String and Session String:
sessionDays = ""
if monSession
sessionDays += "2"
if tueSession
sessionDays += "3"
tradingSession = session + ":" + sessionDays
Constructs a string representing the selected days of the week for the session.

Fetch Session Low and High:
sessLow = SessionLow(tradingSession, timeZone)
sessHigh = SessionHigh(tradingSession, timeZone)
Calls the custom functions to obtain the session low and high prices.

Plot Session Low and High and Background Color for Session
plot(sessLow, color=color.red, title="Session Low")
plot(sessHigh, color=color.red, title="Session Low")
bgcolor(InSession(tradingSession, timeZone) ? color.new(color.aqua, 90) : na)

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?