Professional Documents
Culture Documents
Opening Range
Opening Range
Opening Range
copy
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © marketmindset
//@version=5
indicator("The Opening Range / First Bar By Market Mindset"
, "ORB - Z2E", true
, max_lines_count=500
, max_labels_count = 500)
//---------------------------------------------------------------------------------
----------------
// Constants / Strings
//---------------------------------------------------------------------------------
----------------
AUTO = "Auto"
DAILY = "Daily"
WEEKLY = "Weekly"
MONTHLY = "Monthly"
QUARTERLY = "Quarterly"
HALFYEARLY = "Half Yearly"
YEARLY = "Yearly"
//---------------------------------------------------------------------------------
----------------
// Inputs
//---------------------------------------------------------------------------------
----------------
res = input.string( AUTO , "Resolution" , options=[AUTO, DAILY, WEEKLY,
MONTHLY, QUARTERLY, HALFYEARLY, YEARLY])
timeframe = input.timeframe( "" , "Timeframe", tooltip = "A timeframe higher
than or equls to the chart timeframe is recommended.")
midLine = input.bool( true, "Show Midline")
hist = input.bool( false, "Show Historical Ranges")
get_auto_resolution() =>
resolution = '12M'
if timeframe.isintraday
resolution := timeframe.multiplier <= 15 ? 'D' : 'W'
else if timeframe.isdaily
resolution := 'M'
resolution
start = time(resolution)
isNewPeriod = ta.change(newBar) != 0
//---------------------------------------------------------------------------------
----------------
// Outputs
//---------------------------------------------------------------------------------
----------------
draw_label(y, _txt) =>
_tmptxt = str.tostring(y, format.mintick)
var label _label = na
if isNewPeriod
_top := line.new(start, H, end, H, color = _color , style =
get_style(boxStyle), width=2, xloc = xloc.bar_time)
_bot := line.new(start, L, end, L, color = _color , style =
get_style(boxStyle), width=2, xloc = xloc.bar_time)
linefill.new(_top, _bot, _fillcolor)
if midLine
_mid := line.new(start, M, end, M, color = __color , style =
get_style(lineStyle), width=lineWidth, xloc = xloc.bar_time)
if not hist
line.delete(_top[1])
line.delete(_bot[1])
line.delete(_mid[1])
draw_label(H, "T")
draw_label(L, "B")
if midLine
draw_label(M, "M")