Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Credit:// ©jonico daily session break | ©boitoki session boxes
- //Volumebars ©truece
- // YESTERDAY HI/LO, LASK WK HI/LO
- // Original pattern formation by plasmapug, rise retrace continuation to the upside by infernix, peshocore and xtech5192
- // Range daily/weekly Hi/Lo added with research contributions from xtech5192
- // Please note while the code is open source and you are free to use it however you like - the 'Traders Reality' name is not - ie if you produce derivatives of this
- // source code you to name those scripts using "Traders Reality", "Pattern Watchers" or any other name that relates to Traders Reality in any way.
- //@version=5
- indicator('OFJ', overlay=true, max_bars_back=300,max_boxes_count=500, max_lines_count=500, max_labels_count=500, scale=scale.none)
- ////////
- h = input.int(defval=19, title='Hour', maxval=23, minval=0)
- m = input.int(defval=0, title='Minute', maxval=59, minval=0)
- c = input(defval=color.black, title='color')
- isHour = hour == h
- isMinute = minute == m
- if isHour and isMinute
- line.new(bar_index, low - ta.tr, bar_index, high + ta.tr, xloc.bar_index, extend.both, color=c, style=line.style_dotted, width=1)
- // Config
- label_offset_input = input.int(group='Label offsets', title='General', defval=5, inline='labeloffset1')
- /// market boxes and daily open only on intraday
- bool show = timeframe.isminutes and timeframe.multiplier <= 60 and timeframe.multiplier >= 0
- time_now_exchange = timestamp(year, month, dayofmonth, hour, minute, second)
- string rectStyle = input.string(group='Market sessions', defval='Dashed', title='Line style of Market Session hi/lo line', options=['Dashed', 'Solid'])
- sessLineStyle = line.style_dashed
- bool show_markets = input.bool(true, group='Market sessions', title='Show Market Sessions?', tooltip='Turn on or off all market sessions') and show
- bool show_markets_weekends = input.bool(false, group='Market sessions', title='Show Market Session on Weekends?', tooltip='Turn on or off market sessions in the weekends. Note do not turn this on for exchanges that dont have weekend data like OANDA') and show
- string weekend_sessions = ':1234567'
- string no_weekend_sessions = ':23456'
- bool show_rectangle1 = input.bool(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session1conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
- bool show_label1 = input.bool(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval=true, title='Label?', inline='session1conf') and show_rectangle1 and show_markets
- bool show_or1 = input.bool(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session1conf', tooltip='This controls the shaded area for the session') and show_rectangle1 and show_markets
- string sess1Label = input.string(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval='London', title='Name:', inline='session1style')
- color sess1col = input.color(group='Market session: London (0800-1630 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(200, 123, 134, 85), inline='session1style')
- color sess1colLabel = input.color(group='Market session: London (0800-1630 UTC+0) - DST Aware', title='Label', defval=color.rgb(200, 123, 134, 0), inline='session1style')
- string sess1TimeX = '0800-1630'//input.session(group='Market session: London (0800-1630 UTC+0)', defval='0800-1630', title='Time (UTC+0):', inline='session1style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST and times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
- sess1Time = show_markets_weekends ? sess1TimeX + weekend_sessions : sess1TimeX + no_weekend_sessions
- bool show_rectangle2 = input.bool(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session2conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
- bool show_label2 = input.bool(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval=true, title='Label?', inline='session2conf') and show_rectangle2 and show_markets
- bool show_or2 = input.bool(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session2conf', tooltip='This controls the shaded area for the session') and show_rectangle2 and show_markets
- string sess2Label = input.string(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval='NewYork', title='Name:', inline='session2style')
- color sess2col = input.color(group='Market session: New York (1430-2100 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(251, 86, 91, 85), inline='session2style')
- color sess2colLabel = input.color(group='Market session: New York (1430-2100 UTC+0) - DST Aware', title='Label', defval=color.rgb(253, 84, 87, 0), inline='session2style')
- string sess2TimeX = '1430-2100'//input.session(group='Market session: New York (1430-2100 UTC+0)', defval='1430-2100', title='Time (UTC+0):', inline='session2style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
- sess2Time = show_markets_weekends ? sess2TimeX + weekend_sessions : sess2TimeX + no_weekend_sessions
- bool show_rectangle3 = input.bool(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session3conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
- bool show_label3 = input.bool(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval=true, title='Label?', inline='session3conf') and show_rectangle3 and show_markets
- bool show_or3 = input.bool(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session3conf', tooltip='This controls the shaded area for the session') and show_rectangle3 and show_markets
- string sess3Label = input.string(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval='Tokyo', title='Name:', inline='session3style')
- color sess3col = input.color(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(80, 174, 85, 85), inline='session3style')
- color sess3colLabel = input.color(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', title='Label', defval=color.rgb(80, 174, 85, 0), inline='session3style')
- string sess3TimeX = '0000-0600'//input.session(group='Market session: Tokyo (0000-0600 UTC+0)', defval='0000-0600', title='Time (UTC+0):', inline='session3style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
- sess3Time = show_markets_weekends ? sess3TimeX + weekend_sessions : sess3TimeX + no_weekend_sessions
- bool show_rectangle4 = input.bool(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session4conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
- bool show_label4 = input.bool(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval=true, title='Label?', inline='session4conf') and show_rectangle4 and show_markets
- bool show_or4 = input.bool(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session4conf', tooltip='This controls the shaded area for the session') and show_rectangle4 and show_markets
- string sess4Label = input.string(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval='HongKong', title='Name:', inline='session4style')
- color sess4col = input.color(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(128, 127, 23, 95), inline='session4style')
- color sess4colLabel = input.color(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', title='Label', defval=color.rgb(128, 127, 23, 90), inline='session4style')
- string sess4TimeX = '0130-0800'//input.session(group='Market session: Hong Kong (0130-0800 UTC+0)', defval='0130-0800', title='Time (UTC+0):', inline='session4style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
- sess4Time = show_markets_weekends ? sess4TimeX + weekend_sessions : sess4TimeX + no_weekend_sessions
- bool show_rectangle5 = input.bool(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval=true, title='Show: session?', inline='session5conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
- bool show_label5 = input.bool(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval=true, title='Label?', inline='session5conf') and show_rectangle5 and show_markets
- bool show_or5 = input.bool(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session5conf', tooltip='This controls the shaded area for the session') and show_rectangle5 and show_markets
- string sess5Label = input.string(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval='Sydney', title='Name:', inline='session5style')
- color sess5col = input.color(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(37, 228, 123, 95), inline='session5style')
- color sess5colLabel = input.color(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', title='Label', defval=color.rgb(37, 228, 123, 90), inline='session5style')
- string sess5TimeX = '2200-0600'//input.session(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0)', defval='2200-0600', title='Time (UTC+0):', inline='session5style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
- sess5Time = show_markets_weekends ? sess5TimeX + weekend_sessions : sess5TimeX + no_weekend_sessions
- bool show_rectangle8 = input.bool(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval=false, title='Show: session?', inline='session8conf', tooltip='If this checkbox is off, Label and Open Range have no effect') and show_markets
- bool show_label8 = input.bool(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval=true, title='Label?', inline='session8conf') and show_rectangle8 and show_markets
- bool show_or8 = input.bool(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval=true, title='Opening Range?', inline='session8conf', tooltip='This controls the shaded area for the session') and show_rectangle8 and show_markets
- string sess8Label = input.string(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval='Frankfurt', title='Name:', inline='session8style')
- color sess8col = input.color(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', title='Color: Box', defval=color.rgb(253, 152, 39, 95), inline='session8style')
- color sess8colLabel = input.color(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', title='Label', defval=color.rgb(253, 152, 39, 90), inline='session8style')
- string sess8TimeX = '0700-1630'//input.session(group='Market session: Frankfurt (0700-1630 UTC+0)', defval='0700-1630', title='Time (UTC+0):', inline='session8style', tooltip='Normally you will not want to adjust these times. Defaults are taken as if the session is NOT in DST times must be in UTC+0. Note due to limitations of pinescript some values sellected here other than the default might not work correctly on all exchanges.')
- sess8Time = show_markets_weekends ? sess8TimeX + weekend_sessions : sess8TimeX + no_weekend_sessions
- //Non repainting security
- f_security(_symbol, _res, _src, _repaint) =>
- request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1]
- // Basic vars (needed in functions)
- // Only render intraday
- validTimeFrame = timeframe.isintraday == true
- // If above the 5 minute, we start drawing yesterday. below, we start today
- levelsstart = timeframe.isseconds == true or timeframe.isminutes == true and timeframe.multiplier < 5 ? time('D') : time('D') - 86400 * 1000
- //levelsstartbar = ta.barssince(levelsstart)
- // Functions
- // new_bar: check if we're on a new bar within the session in a given resolution
- new_bar(res) =>
- ta.change(time(res)) != 0
- label_x_offset = time_close + label_offset_input * timeframe.multiplier * 60 * 1000
- //Right_Label
- r_label(ry, rtext, rstyle, rcolor, valid) =>
- var label rLabel = na
- if valid and barstate.isrealtime
- rLabel := label.new(x=label_x_offset, y=ry, text=rtext, xloc=xloc.bar_time, style=rstyle, textcolor=rcolor, textalign=text.align_right)
- label.delete(rLabel[1])
- rLabel
- //Right_Label
- r_label_offset(ry, rtext, rstyle, rcolor, valid, labelOffset) =>
- if valid and barstate.isrealtime
- rLabel = label.new(x=labelOffset, y=ry, text=rtext, xloc=xloc.bar_time, style=rstyle, textcolor=rcolor, textalign=text.align_right)
- label.delete(rLabel[1])
- draw_line(x_series, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, xLabelOffset) =>
- var line x_line = na
- if validTimeFrame and new_bar(res) //and barstate.isnew
- x_line := line.new(bar_index, x_series, bar_index+1, x_series, extend=xExtend, color=xColor, style=xStyle, width=xWidth)
- line.delete(x_line[1])
- if not na(x_line) and not new_bar(res)//and line.get_x2(x_line) != bar_index
- line.set_x2(x_line, bar_index)
- line.set_y1(x_line,x_series)
- line.set_y2(x_line,x_series)
- if isLabelValid //showADRLabels and validTimeFrame
- x_label = label.new(xLabelOffset, x_series, tag, xloc=xloc.bar_time, style=label.style_none, textcolor=xColor)
- label.delete(x_label[1])
- //*****************
- // Market sessions
- //*****************
- splitSessionString(sessXTime) =>
- //session stirng looks like this: 0000-0000:1234567 ie start time, end time, day of the week
- //we need to parse the sessXTime string into hours and min for start and end times so we can use those in the timestampfunction below
- //string times contains "0000-2300" as an example
- string times = array.get(str.split(sessXTime, ':'), 0)
- //string startTime contains "0000"
- string startTime = array.get(str.split(times, '-'), 0)
- //string endTime contains "2300"
- string endTime = array.get(str.split(times, '-'), 1)
- //now we need to get the start hour and start min, sing 0 index - hour is the characters in index 0 and index 1 while min is the chars at index 2 and 3
- string[] startTimeChars = str.split(startTime, '')
- string[] endTimeChars = str.split(endTime, '')
- //so now startHour contains 00 and start min contains 00
- string startHour = array.get(startTimeChars, 0) + array.get(startTimeChars, 1)
- string startMin = array.get(startTimeChars, 2) + array.get(startTimeChars, 3)
- //so now endHour contains 23 and end min contains 00
- string endHour = array.get(endTimeChars, 0) + array.get(endTimeChars, 1)
- string endMin = array.get(endTimeChars, 2) + array.get(endTimeChars, 3)
- [startHour, startMin, endHour, endMin]
- calc_session_startend(sessXTime, gmt) =>
- [startHour, startMin, endHour, endMin] = splitSessionString(sessXTime)
- targetstartTimeX = timestamp(gmt, year, month, dayofmonth, math.round(str.tonumber(startHour)), math.round(str.tonumber(startMin)), 00)
- targetendTimeX = timestamp(gmt, year, month, dayofmonth, math.round(str.tonumber(endHour)), math.round(str.tonumber(endMin)), 00)
- time_now = timestamp(year, month, dayofmonth, hour, minute, 00)
- midnight_exchange = timestamp(year, month, dayofmonth, 00, 00, 00)
- //if start hour is greater than end hour we are dealing with a session that starts towards the end of one day
- //and ends the next day. ie advance the end time by 24 hours - its the next day
- bool adjusted = false
- if gmt == 'GMT+0'
- if math.round(str.tonumber(startHour)) > math.round(str.tonumber(endHour))
- if time_now - targetstartTimeX >= 0
- targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
- adjusted := true
- targetendTimeX
- if gmt == 'GMT+1'
- if math.round(str.tonumber(startHour)) == 0
- startHour := '24'
- if math.round(str.tonumber(endHour)) == 0
- endHour := '24'
- if math.round(str.tonumber(startHour))-1 > math.round(str.tonumber(endHour))-1
- if time_now - targetstartTimeX >= 0
- targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
- adjusted := true
- targetendTimeX
- //now is the exchange is at some utc offset and the market session crosses days even when start hour is not greater than end hour
- //we still need to adjust the end time.
- if targetstartTimeX < midnight_exchange and midnight_exchange < targetendTimeX and not adjusted
- targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
- targetendTimeX
- [targetstartTimeX,targetendTimeX]
- draw_open_range(sessXTime, sessXcol, show_orX, gmt)=>
- if show_orX
- // Initialize variables on bar zero only, so they preserve their values across bars.
- var hi = float(na)
- var lo = float(na)
- var box hiLoBox = na
- // Detect changes in timeframe.
- session = time(timeframe.period, sessXTime, gmt)
- bool newTF = session and not session[1]
- if newTF
- // New bar in higher timeframe; reset values and create new lines and box.
- [targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime, gmt)
- sessionDuration = math.round(math.abs(time - targetendTimeX)/(timeframe.multiplier*60*1000))
- hi := high
- lo := low
- hiLoBox := box.new(bar_index, hi, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, lo, border_color = na, bgcolor = sessXcol)
- int(na)
- else
- if timeframe.multiplier == 1 and (na(session[1]) and not na(session) or session[1] < session)
- box.set_right(hiLoBox, bar_index+1)
- int(na)
- draw_session_hilo(sessXTime, show_rectangleX, show_labelX, sessXcolLabel, sessXLabel, gmt)=>
- if show_rectangleX
- // Initialize variables on bar zero only, so they preserve their values across bars.
- var hi = float(0)
- var lo = float(10000000000.0)
- var line line_t = na
- var line line_b = na
- var label line_label = na
- // var box hiLoBox = na
- // Detect changes in timeframe.
- session = time(timeframe.period, sessXTime, gmt)
- sessLineStyleX = rectStyle == 'Solid' ? line.style_solid : line.style_dashed
- bool newTF = session and not session[1]
- hi := newTF ? high : session ? math.max(high, hi[1]) : hi[1]
- lo := newTF ? low : session ? math.min(low, lo[1]) : lo[1]
- if newTF
- beginIndex = bar_index
- [targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime, gmt)
- sessionDuration = math.round(math.abs(time - targetendTimeX)/(timeframe.multiplier*60*1000))
- line_t := line.new(beginIndex, hi, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, hi, xloc=xloc.bar_index, style=sessLineStyleX, color=sessXcolLabel)
- line_b := line.new(beginIndex, lo, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, lo, xloc=xloc.bar_index, style=sessLineStyleX, color=sessXcolLabel)
- line.delete(line_t[1])
- line.delete(line_b[1])
- if show_labelX
- line_label := label.new(beginIndex, hi, sessXLabel, xloc=xloc.bar_index, textcolor=sessXcolLabel, style=label.style_none, size=size.normal, textalign=text.align_right)
- label.delete(line_label[1])
- int(na)
- else
- if na(session[1]) and not na(session) or session[1] < session
- if timeframe.multiplier == 1
- line.set_x2(line_t,bar_index+1)
- line.set_x2(line_b,bar_index+1)
- line.set_y1(line_t,hi)
- line.set_y2(line_t,hi)
- line.set_y1(line_b,lo)
- line.set_y2(line_b,lo)
- if show_labelX and not na(line_label)
- label.set_y(line_label, hi)
- int(na)
- //*****************************//
- // Daylight Savings Time Flags //
- //*****************************//
- int previousSunday = dayofmonth - dayofweek + 1
- bool nyDST = na
- bool ukDST = na
- bool sydDST = na
- if month < 3 or month > 11
- nyDST := false
- ukDST := false
- sydDST := true
- else if month > 4 and month < 10
- nyDST := true
- ukDST := true
- sydDST := false
- else if month == 3
- nyDST := previousSunday >= 8
- ukDST := previousSunday >= 24
- sydDST := true
- else if month == 4
- nyDST := true
- ukDST := true
- sydDST := previousSunday <= 0
- else if month == 10
- nyDST := true
- ukDST := previousSunday <= 24
- sydDST := previousSunday >= 0
- else // month == 11
- nyDST := previousSunday <= 0
- ukDST := false
- sydDST := true
- if ukDST
- draw_open_range(sess1Time,sess1col,show_or1,'GMT+1')
- draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel, sess1Label, 'GMT+1')
- else
- draw_open_range(sess1Time,sess1col,show_or1,'GMT+0')
- draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel, sess1Label, 'GMT+0')
- if nyDST
- draw_open_range(sess2Time,sess2col,show_or2,'GMT+1')
- draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel, sess2Label, 'GMT+1')
- else
- draw_open_range(sess2Time,sess2col,show_or2,'GMT+0')
- draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel, sess2Label, 'GMT+0')
- // Tokyo
- draw_open_range(sess3Time,sess3col,show_or3,'GMT+0')
- draw_session_hilo(sess3Time, show_rectangle3, show_label3, sess3colLabel, sess3Label, 'GMT+0')
- // Hong Kong
- draw_open_range(sess4Time,sess4col,show_or4,'GMT+0')
- draw_session_hilo(sess4Time, show_rectangle4, show_label4, sess4colLabel, sess4Label, 'GMT+0')
- if sydDST
- draw_open_range(sess5Time,sess5col,show_or5,'GMT+1')
- draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel, sess5Label, 'GMT+1')
- else
- draw_open_range(sess5Time,sess5col,show_or5,'GMT+0')
- draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel, sess5Label, 'GMT+0')
- //becuase frankfurt changes with london
- if ukDST
- draw_open_range(sess8Time,sess8col,show_or8,'GMT+1')
- draw_session_hilo(sess8Time, show_rectangle8, show_label8, sess8colLabel, sess8Label, 'GMT+1')
- else
- draw_open_range(sess8Time,sess8col,show_or8,'GMT+0')
- draw_session_hilo(sess8Time, show_rectangle8, show_label8, sess8colLabel, sess8Label, 'GMT+0')
- //@version=5
- //@mrSebastienC thank you for doing the base code
- //Added additional levels for convienience sake.
- //35 works
- displayStyle = input.string(defval='Standard', title='Display Style', options=['Standard', 'Right Anchored'], inline='Display')
- mergebool = input.bool(defval=true, title='Merge Levels?', inline='Display')
- distanceright = input.int(defval=30, title='Distance', minval=5, maxval=500, inline='Dist')
- radistance = input.int(defval=250, title='Anchor Distance', minval=5, maxval=500, inline='Dist')
- labelsize = input.string(defval='Medium', title='Text Size', options=['Small', 'Medium', 'Large'])
- linesize = input.string(defval='Small', title='Line Width', options=['Small', 'Medium', 'Large'], inline='Line')
- linestyle = input.string(defval='Solid', title='Line Style', options=['Solid', 'Dashed', 'Dotted'], inline='Line')
- GlobalTextType = input.bool(defval=true, title='Global Text ShortHand', tooltip='Enable for shorthand text on all text')
- var globalcoloring = input.bool(defval=false, title='Global Coloring', tooltip='Enable for all color controls via one color', inline='GC')
- GlobalColor = input.color(title='', defval=#03abff, inline='GC')
- //var show_tails = input(defval = false, title = "Always Show", type = input.bool)
- [daily_time, daily_open] = request.security(syminfo.tickerid, 'D', [time, open], lookahead=barmerge.lookahead_on)
- [dailyh_time, dailyh_open] = request.security(syminfo.tickerid, 'D', [time[1], high[1]], lookahead=barmerge.lookahead_on)
- [dailyl_time, dailyl_open] = request.security(syminfo.tickerid, 'D', [time[1], low[1]], lookahead=barmerge.lookahead_on)
- cdailyh_open = request.security(syminfo.tickerid, 'D', high, lookahead=barmerge.lookahead_on)
- cdailyl_open = request.security(syminfo.tickerid, 'D', low, lookahead=barmerge.lookahead_on)
- var monday_time = time
- var monday_high = high
- var monday_low = low
- [weekly_time, weekly_open] = request.security(syminfo.tickerid, 'W', [time, open], lookahead=barmerge.lookahead_on)
- [weeklyh_time, weeklyh_open] = request.security(syminfo.tickerid, 'W', [time[1], high[1]], lookahead=barmerge.lookahead_on)
- [weeklyl_time, weeklyl_open] = request.security(syminfo.tickerid, 'W', [time[1], low[1]], lookahead=barmerge.lookahead_on)
- [monthly_time, monthly_open] = request.security(syminfo.tickerid, 'M', [time, open], lookahead=barmerge.lookahead_on)
- [monthlyh_time, monthlyh_open] = request.security(syminfo.tickerid, 'M', [time[1], high[1]], lookahead=barmerge.lookahead_on)
- [monthlyl_time, monthlyl_open] = request.security(syminfo.tickerid, 'M', [time[1], low[1]], lookahead=barmerge.lookahead_on)
- [quarterly_time, quarterly_open] = request.security(syminfo.tickerid, '3M', [time, open], lookahead=barmerge.lookahead_on)
- [quarterlyh_time, quarterlyh_open] = request.security(syminfo.tickerid, '3M', [time[1], high[1]], lookahead=barmerge.lookahead_on)
- [quarterlyl_time, quarterlyl_open] = request.security(syminfo.tickerid, '3M', [time[1], low[1]], lookahead=barmerge.lookahead_on)
- [yearly_time, yearly_open] = request.security(syminfo.tickerid, '12M', [time, open], lookahead=barmerge.lookahead_on)
- [yearlyh_time, yearlyh_open] = request.security(syminfo.tickerid, '12M', [time, high], lookahead=barmerge.lookahead_on)
- [yearlyl_time, yearlyl_open] = request.security(syminfo.tickerid, '12M', [time, low], lookahead=barmerge.lookahead_on)
- [intra_time, intra_open] = request.security(syminfo.tickerid, '240', [time, open], lookahead=barmerge.lookahead_on)
- [intrah_time, intrah_open] = request.security(syminfo.tickerid, '240', [time[1], high[1]], lookahead=barmerge.lookahead_on)
- [intral_time, intral_open] = request.security(syminfo.tickerid, '240', [time[1], low[1]], lookahead=barmerge.lookahead_on)
- //------------------------------ Inputs -------------------------------
- var is_intra_enabled = input.bool(defval=false, title='Open', group='4H', inline='4H')
- var is_intrarange_enabled = input.bool(defval=false, title='Prev H/L', group='4H', inline='4H')
- var is_intram_enabled = input.bool(defval=false, title='Prev Mid', group='4H', inline='4H')
- IntraTextType = input.bool(defval=false, title='ShortHand', group='4H', inline='4Hsh')
- var is_daily_enabled = input.bool(defval=true, title='Open', group='Daily', inline='Daily')
- var is_dailyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Daily', inline='Daily')
- var is_dailym_enabled = input.bool(defval=false, title='Prev Mid', group='Daily', inline='Daily')
- DailyTextType = input.bool(defval=false, title='ShortHand', group='Daily', inline='Dailysh')
- var is_monday_enabled = input.bool(defval=true, title='Range', group='Monday Range', inline='Monday')
- var is_monday_mid = input.bool(defval=false, title='Mid', group='Monday Range', inline='Monday')
- var untested_monday = false
- MondayTextType = input.bool(defval=false, title='ShortHand', group='Monday Range', inline='Mondaysh')
- var is_weekly_enabled = input.bool(defval=true, title='Open', group='Weekly', inline='Weekly')
- var is_weeklyrange_enabled = input.bool(defval=true, title='Prev H/L', group='Weekly', inline='Weekly')
- var is_weekly_mid = input.bool(defval=true, title='Prev Mid', group='Weekly', inline='Weekly')
- WeeklyTextType = input.bool(defval=false, title='ShortHand', group='Weekly', inline='Weeklysh')
- var is_monthly_enabled = input.bool(defval=true, title='Open', group='Monthly', inline='Monthly')
- var is_monthlyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Monthly', inline='Monthly')
- var is_monthly_mid = input.bool(defval=false, title='Prev Mid', group='Monthly', inline='Monthly')
- MonthlyTextType = input.bool(defval=false, title='ShortHand', group='Monthly', inline='Monthlysh')
- var is_quarterly_enabled = input.bool(defval=false, title='Open', group='Quarterly', inline='Quarterly')
- var is_quarterlyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Quarterly', inline='Quarterly')
- var is_quarterly_mid = input.bool(defval=false, title='Prev Mid', group='Quarterly', inline='Quarterly')
- QuarterlyTextType = input.bool(defval=false, title='ShortHand', group='Quarterly', inline='Quarterlysh')
- var is_yearly_enabled = input.bool(defval=false, title='Open', group='Yearly', inline='Yearly')
- var is_yearlyrange_enabled = input.bool(defval=false, title='Current H/L', group='Yearly', inline='Yearly')
- var is_yearly_mid = input.bool(defval=false, title='Mid', group='Yearly', inline='Yearly')
- YearlyTextType = input.bool(defval=false, title='ShortHand', group='Yearly', inline='Yearlysh')
- DailyColor = input.color(title='', defval=#08bcd4, group='Daily', inline='Dailysh')
- MondayColor = input.color(title='', defval=color.white, group='Monday Range', inline='Mondaysh')
- WeeklyColor = input.color(title='', defval=#fffcbc, group='Weekly', inline='Weeklysh')
- MonthlyColor = input.color(title='', defval=#08d48c, group='Monthly', inline='Monthlysh')
- YearlyColor = input.color(title='', defval=color.red, group='Yearly', inline='Yearlysh')
- quarterlyColor = input.color(title='', defval=color.red, group='Quarterly', inline='Quarterlysh')
- IntraColor = input.color(title='', defval=color.orange, group='4H', inline='4Hsh')
- var pdhtext = GlobalTextType or DailyTextType ? 'PDH' : 'Prev Day High'
- var pdltext = GlobalTextType or DailyTextType ? 'PDL' : 'Prev Day Low'
- var dotext = GlobalTextType or DailyTextType ? 'DO' : 'Daily Open'
- var pdmtext = GlobalTextType or DailyTextType ? 'PDM' : 'Prev Day Mid'
- var pwhtext = GlobalTextType or WeeklyTextType ? 'PWH' : 'Prev Week High'
- var pwltext = GlobalTextType or WeeklyTextType ? 'PWL' : 'Prev Week Low'
- var wotext = GlobalTextType or WeeklyTextType ? 'WO' : 'Weekly Open'
- var pwmtext = GlobalTextType or WeeklyTextType ? 'PWM' : 'Prev Week Mid'
- var pmhtext = GlobalTextType or MonthlyTextType ? 'PMH' : 'Prev Month High'
- var pmltext = GlobalTextType or MonthlyTextType ? 'PML' : 'Prev Month Low'
- var motext = GlobalTextType or MonthlyTextType ? 'MO' : 'Monthly Open'
- var pmmtext = GlobalTextType or MonthlyTextType ? 'PMM' : 'Prev Month Mid'
- var pqhtext = GlobalTextType or QuarterlyTextType ? 'PQH' : 'Prev Quarter High'
- var pqltext = GlobalTextType or QuarterlyTextType ? 'PQL' : 'Prev Quarter Low'
- var qotext = GlobalTextType or QuarterlyTextType ? 'QO' : 'Quarterly Open'
- var pqmtext = GlobalTextType or QuarterlyTextType ? 'PQM' : 'Prev Quarter Mid'
- var cyhtext = GlobalTextType or YearlyTextType ? 'CYH' : 'Current Year High'
- var cyltext = GlobalTextType or YearlyTextType ? 'CYL' : 'Current Year Low'
- var yotext = GlobalTextType or YearlyTextType ? 'YO' : 'Yearly Open'
- var cymtext = GlobalTextType or YearlyTextType ? 'CYM' : 'Current Year Mid'
- var pihtext = GlobalTextType or IntraTextType ? 'P-4H-H' : 'Prev 4H High'
- var piltext = GlobalTextType or IntraTextType ? 'P-4H-L' : 'Prev 4H Low'
- var iotext = GlobalTextType or IntraTextType ? '4H-O' : '4H Open'
- var pimtext = GlobalTextType or IntraTextType ? 'P-4H-M' : 'Prev 4H Mid'
- var pmonhtext = GlobalTextType or MondayTextType ? 'MDAY-H' : 'Monday High'
- var pmonltext = GlobalTextType or MondayTextType ? 'MDAY-L' : 'Monday Low'
- var pmonmtext = GlobalTextType or MondayTextType ? 'MDAY-M' : 'Monday Mid'
- if globalcoloring == true
- DailyColor := GlobalColor
- MondayColor := GlobalColor
- WeeklyColor := GlobalColor
- MonthlyColor := GlobalColor
- YearlyColor := GlobalColor
- quarterlyColor := GlobalColor
- IntraColor := GlobalColor
- IntraColor
- if weekly_time != weekly_time[1]
- untested_monday := false
- untested_monday
- if is_monday_enabled == true and untested_monday == false
- untested_monday := true
- monday_time := daily_time
- monday_high := cdailyh_open
- monday_low := cdailyl_open
- monday_low
- linewidthint = 1
- if linesize == 'Small'
- linewidthint := 1
- linewidthint
- if linesize == 'Medium'
- linewidthint := 2
- linewidthint
- if linesize == 'Large'
- linewidthint := 3
- linewidthint
- var DEFAULT_LINE_WIDTH = linewidthint
- var DEFAULT_TAIL_WIDTH = linewidthint
- fontsize = size.small
- if labelsize == 'Small'
- fontsize := size.small
- fontsize
- if labelsize == 'Medium'
- fontsize := size.normal
- fontsize
- if labelsize == 'Large'
- fontsize := size.large
- fontsize
- linestyles = line.style_solid
- if linestyle == 'Dashed'
- linestyles := line.style_dashed
- linestyles
- if linestyle == 'Dotted'
- linestyles := line.style_dotted
- linestyles
- var DEFAULT_LABEL_SIZE = fontsize
- var DEFAULT_LABEL_STYLE = label.style_none
- var DEFAULT_EXTEND_RIGHT = distanceright
- //------------------------------ Plotting ------------------------------
- var pricearray = array.new_float(0)
- var labelarray = array.new_label(0)
- f_LevelMerge(pricearray, labelarray, currentprice, currentlabel, currentcolor) =>
- if array.includes(pricearray, currentprice)
- whichindex = array.indexof(pricearray, currentprice)
- labelhold = array.get(labelarray, whichindex)
- whichtext = label.get_text(labelhold)
- label.set_text(labelhold, label.get_text(currentlabel) + ' / ' + whichtext)
- label.set_text(currentlabel, '')
- label.set_textcolor(labelhold, currentcolor)
- else
- array.push(pricearray, currentprice)
- array.push(labelarray, currentlabel)
- var can_show_daily = is_daily_enabled and timeframe.isintraday
- var can_show_weekly = is_weekly_enabled and not timeframe.isweekly and not timeframe.ismonthly
- var can_show_monthly = is_monthly_enabled and not timeframe.ismonthly
- get_limit_right(bars) =>
- timenow + (time - time[1]) * bars
- // the following code doesn't need to be processed on every candle
- if barstate.islast
- is_weekly_open = dayofweek == dayofweek.monday
- is_monthly_open = dayofmonth == 1
- can_draw_daily = (is_weekly_enabled ? not is_weekly_open : true) and (is_monthly_enabled ? not is_monthly_open : true)
- can_draw_weekly = is_monthly_enabled ? not(is_monthly_open and is_weekly_open) : true
- can_draw_intra = is_intra_enabled
- can_draw_intrah = is_intrarange_enabled
- can_draw_intral = is_intrarange_enabled
- can_draw_intram = is_intram_enabled
- pricearray := array.new_float(0)
- labelarray := array.new_label(0)
- /////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////
- if can_draw_intra
- intra_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- intra_time := get_limit_right(radistance)
- intra_time
- var intra_line = line.new(x1=intra_time, x2=intra_limit_right, y1=intra_open, y2=intra_open, color=IntraColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var intra_label = label.new(x=intra_limit_right, y=intra_open, text=iotext, style=DEFAULT_LABEL_STYLE, textcolor=IntraColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(intra_line, intra_time)
- line.set_x2(intra_line, intra_limit_right)
- line.set_y1(intra_line, intra_open)
- line.set_y2(intra_line, intra_open)
- label.set_x(intra_label, intra_limit_right)
- label.set_y(intra_label, intra_open)
- label.set_text(intra_label, iotext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, intra_open, intra_label, IntraColor)
- //////////////////////////////////////////////////////////////////////////////////
- //HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH
- if can_draw_intrah
- intrah_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- intrah_time := get_limit_right(radistance)
- intrah_time
- var intrah_line = line.new(x1=intrah_time, x2=intrah_limit_right, y1=intrah_open, y2=intrah_open, color=IntraColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var intrah_label = label.new(x=intrah_limit_right, y=intrah_open, text=pihtext, style=DEFAULT_LABEL_STYLE, textcolor=IntraColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(intrah_line, intrah_time)
- line.set_x2(intrah_line, intrah_limit_right)
- line.set_y1(intrah_line, intrah_open)
- line.set_y2(intrah_line, intrah_open)
- label.set_x(intrah_label, intrah_limit_right)
- label.set_y(intrah_label, intrah_open)
- label.set_text(intrah_label, pihtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, intrah_open, intrah_label, IntraColor)
- //////////////////////////////////////////////////////////////////////////////////
- //LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW
- if can_draw_intral
- intral_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- intral_time := get_limit_right(radistance)
- intral_time
- var intral_line = line.new(x1=intral_time, x2=intral_limit_right, y1=intral_open, y2=intral_open, color=IntraColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var intral_label = label.new(x=intral_limit_right, y=intral_open, text=piltext, style=DEFAULT_LABEL_STYLE, textcolor=IntraColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(intral_line, intral_time)
- line.set_x2(intral_line, intral_limit_right)
- line.set_y1(intral_line, intral_open)
- line.set_y2(intral_line, intral_open)
- label.set_x(intral_label, intral_limit_right)
- label.set_y(intral_label, intral_open)
- label.set_text(intral_label, piltext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, intral_open, intral_label, IntraColor)
- ///////////////////////////////////////////////////////////////////////////////
- if can_draw_intram
- intram_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- intram_time = intrah_time
- intram_open = (intral_open + intrah_open) / 2
- if displayStyle == 'Right Anchored'
- intram_time := get_limit_right(radistance)
- intram_time
- var intram_line = line.new(x1=intram_time, x2=intram_limit_right, y1=intram_open, y2=intram_open, color=IntraColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var intram_label = label.new(x=intram_limit_right, y=intram_open, text=pimtext, style=DEFAULT_LABEL_STYLE, textcolor=IntraColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(intram_line, intram_time)
- line.set_x2(intram_line, intram_limit_right)
- line.set_y1(intram_line, intram_open)
- line.set_y2(intram_line, intram_open)
- label.set_x(intram_label, intram_limit_right)
- label.set_y(intram_label, intram_open)
- label.set_text(intram_label, pimtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, intram_open, intram_label, IntraColor)
- ////////////////////////////////////////// MONDAY
- if is_monday_enabled
- monday_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- monday_time := get_limit_right(radistance)
- monday_time
- var monday_line = line.new(x1=monday_time, x2=monday_limit_right, y1=monday_high, y2=monday_high, color=MondayColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var monday_label = label.new(x=monday_limit_right, y=monday_high, text=pmonhtext, style=DEFAULT_LABEL_STYLE, textcolor=MondayColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(monday_line, monday_time)
- line.set_x2(monday_line, monday_limit_right)
- line.set_y1(monday_line, monday_high)
- line.set_y2(monday_line, monday_high)
- label.set_x(monday_label, monday_limit_right)
- label.set_y(monday_label, monday_high)
- label.set_text(monday_label, pmonhtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, monday_high, monday_label, MondayColor)
- if is_monday_enabled
- monday_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- monday_time := get_limit_right(radistance)
- monday_time
- var monday_low_line = line.new(x1=monday_time, x2=monday_limit_right, y1=monday_low, y2=monday_low, color=MondayColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var monday_low_label = label.new(x=monday_limit_right, y=monday_low, text=pmonltext, style=DEFAULT_LABEL_STYLE, textcolor=MondayColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(monday_low_line, monday_time)
- line.set_x2(monday_low_line, monday_limit_right)
- line.set_y1(monday_low_line, monday_low)
- line.set_y2(monday_low_line, monday_low)
- label.set_x(monday_low_label, monday_limit_right)
- label.set_y(monday_low_label, monday_low)
- label.set_text(monday_low_label, pmonltext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, monday_low, monday_low_label, MondayColor)
- if is_monday_mid
- mondaym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- mondaym_open = (monday_high + monday_low) / 2
- if displayStyle == 'Right Anchored'
- monday_time := get_limit_right(radistance)
- monday_time
- var mondaym_line = line.new(x1=monday_time, x2=mondaym_limit_right, y1=mondaym_open, y2=mondaym_open, color=MondayColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var mondaym_label = label.new(x=mondaym_limit_right, y=mondaym_open, text=pmonmtext, style=DEFAULT_LABEL_STYLE, textcolor=MondayColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(mondaym_line, monday_time)
- line.set_x2(mondaym_line, mondaym_limit_right)
- line.set_y1(mondaym_line, mondaym_open)
- line.set_y2(mondaym_line, mondaym_open)
- label.set_x(mondaym_label, mondaym_limit_right)
- label.set_y(mondaym_label, mondaym_open)
- label.set_text(mondaym_label, pmonmtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, mondaym_open, mondaym_label, MondayColor)
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN
- if is_daily_enabled
- daily_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- daily_time := get_limit_right(radistance)
- daily_time
- var daily_line = line.new(x1=daily_time, x2=daily_limit_right, y1=daily_open, y2=daily_open, color=DailyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var daily_label = label.new(x=daily_limit_right, y=daily_open, text=dotext, style=DEFAULT_LABEL_STYLE, textcolor=DailyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(daily_line, daily_time)
- line.set_x2(daily_line, daily_limit_right)
- line.set_y1(daily_line, daily_open)
- line.set_y2(daily_line, daily_open)
- label.set_x(daily_label, daily_limit_right)
- label.set_y(daily_label, daily_open)
- label.set_text(daily_label, dotext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, daily_open, daily_label, DailyColor)
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH
- if is_dailyrange_enabled
- dailyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- dailyh_time := get_limit_right(radistance)
- dailyh_time
- // draw tails before lines for better visual
- var dailyh_line = line.new(x1=dailyh_time, x2=dailyh_limit_right, y1=dailyh_open, y2=dailyh_open, color=DailyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var dailyh_label = label.new(x=dailyh_limit_right, y=dailyh_open, text=pdhtext, style=DEFAULT_LABEL_STYLE, textcolor=DailyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(dailyh_line, dailyh_time)
- line.set_x2(dailyh_line, dailyh_limit_right)
- line.set_y1(dailyh_line, dailyh_open)
- line.set_y2(dailyh_line, dailyh_open)
- label.set_x(dailyh_label, dailyh_limit_right)
- label.set_y(dailyh_label, dailyh_open)
- label.set_text(dailyh_label, pdhtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, dailyh_open, dailyh_label, DailyColor)
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW
- if is_dailyrange_enabled
- dailyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- dailyl_time := get_limit_right(radistance)
- dailyl_time
- var dailyl_line = line.new(x1=dailyl_time, x2=dailyl_limit_right, y1=dailyl_open, y2=dailyl_open, color=DailyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var dailyl_label = label.new(x=dailyl_limit_right, y=dailyl_open, text=pdltext, style=DEFAULT_LABEL_STYLE, textcolor=DailyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(dailyl_line, dailyl_time)
- line.set_x2(dailyl_line, dailyl_limit_right)
- line.set_y1(dailyl_line, dailyl_open)
- line.set_y2(dailyl_line, dailyl_open)
- label.set_x(dailyl_label, dailyl_limit_right)
- label.set_y(dailyl_label, dailyl_open)
- label.set_text(dailyl_label, pdltext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, dailyl_open, dailyl_label, DailyColor)
- //////////////////////////////////////////////////////////////////////////////// Daily MID
- if is_dailym_enabled
- dailym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- dailym_time = dailyh_time
- dailym_open = (dailyl_open + dailyh_open) / 2
- if displayStyle == 'Right Anchored'
- dailym_time := get_limit_right(radistance)
- dailym_time
- var dailym_line = line.new(x1=dailym_time, x2=dailym_limit_right, y1=dailym_open, y2=dailym_open, color=DailyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var dailym_label = label.new(x=dailym_limit_right, y=dailym_open, text=pdmtext, style=DEFAULT_LABEL_STYLE, textcolor=DailyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(dailym_line, dailym_time)
- line.set_x2(dailym_line, dailym_limit_right)
- line.set_y1(dailym_line, dailym_open)
- line.set_y2(dailym_line, dailym_open)
- label.set_x(dailym_label, dailym_limit_right)
- label.set_y(dailym_label, dailym_open)
- label.set_text(dailym_label, pdmtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, dailym_open, dailym_label, DailyColor)
- //////////////////////////////////////////////////////////////////////////////////
- if is_weekly_enabled
- weekly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- cweekly_time = weekly_time
- if displayStyle == 'Right Anchored'
- cweekly_time := get_limit_right(radistance)
- cweekly_time
- var weekly_line = line.new(x1=cweekly_time, x2=weekly_limit_right, y1=weekly_open, y2=weekly_open, color=WeeklyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var weekly_label = label.new(x=weekly_limit_right, y=weekly_open, text=wotext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(weekly_line, cweekly_time)
- line.set_x2(weekly_line, weekly_limit_right)
- line.set_y1(weekly_line, weekly_open)
- line.set_y2(weekly_line, weekly_open)
- label.set_x(weekly_label, weekly_limit_right)
- label.set_y(weekly_label, weekly_open)
- label.set_text(weekly_label, wotext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, weekly_open, weekly_label, WeeklyColor)
- // the weekly open can be the daily open too (monday)
- // only the weekly will be draw, in these case we update its label
- // if is_weekly_open and can_show_daily
- // label.set_text(weekly_label, "DO / WO ")
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////// WEEKLY HIGH WEEKLY HIGH WEEKLY HIGH
- if is_weeklyrange_enabled
- weeklyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- weeklyh_time := get_limit_right(radistance)
- weeklyh_time
- var weeklyh_line = line.new(x1=weeklyh_time, x2=weeklyh_limit_right, y1=weeklyh_open, y2=weeklyh_open, color=WeeklyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var weeklyh_label = label.new(x=weeklyh_limit_right, y=weeklyh_open, text=pwhtext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(weeklyh_line, weeklyh_time)
- line.set_x2(weeklyh_line, weeklyh_limit_right)
- line.set_y1(weeklyh_line, weeklyh_open)
- line.set_y2(weeklyh_line, weeklyh_open)
- label.set_x(weeklyh_label, weeklyh_limit_right)
- label.set_y(weeklyh_label, weeklyh_open)
- label.set_text(weeklyh_label, pwhtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, weeklyh_open, weeklyh_label, WeeklyColor)
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////// WEEKLY LOW WEEKLY LOW WEEKLY LOW
- if is_weeklyrange_enabled
- weeklyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- weeklyl_time := get_limit_right(radistance)
- weeklyl_time
- var weeklyl_line = line.new(x1=weeklyl_time, x2=weeklyl_limit_right, y1=weekly_open, y2=weekly_open, color=WeeklyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var weeklyl_label = label.new(x=weeklyl_limit_right, y=weeklyl_open, text=pwltext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(weeklyl_line, weeklyl_time)
- line.set_x2(weeklyl_line, weeklyl_limit_right)
- line.set_y1(weeklyl_line, weeklyl_open)
- line.set_y2(weeklyl_line, weeklyl_open)
- label.set_x(weeklyl_label, weeklyl_limit_right)
- label.set_y(weeklyl_label, weeklyl_open)
- label.set_text(weeklyl_label, pwltext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, weeklyl_open, weeklyl_label, WeeklyColor)
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////// Weekly MID
- if is_weekly_mid
- weeklym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- weeklym_time = weeklyh_time
- weeklym_open = (weeklyl_open + weeklyh_open) / 2
- if displayStyle == 'Right Anchored'
- weeklym_time := get_limit_right(radistance)
- weeklym_time
- var weeklym_line = line.new(x1=weeklym_time, x2=weeklym_limit_right, y1=weeklym_open, y2=weeklym_open, color=WeeklyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var weeklym_label = label.new(x=weeklym_limit_right, y=weeklym_open, text=pwmtext, style=DEFAULT_LABEL_STYLE, textcolor=WeeklyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(weeklym_line, weeklym_time)
- line.set_x2(weeklym_line, weeklym_limit_right)
- line.set_y1(weeklym_line, weeklym_open)
- line.set_y2(weeklym_line, weeklym_open)
- label.set_x(weeklym_label, weeklym_limit_right)
- label.set_y(weeklym_label, weeklym_open)
- label.set_text(weeklym_label, pwmtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, weeklym_open, weeklym_label, WeeklyColor)
- ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY LOW LOW LOW
- if is_yearlyrange_enabled
- yearlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- yearlyl_time := get_limit_right(radistance)
- yearlyl_time
- var yearlyl_line = line.new(x1=yearlyl_time, x2=yearlyl_limit_right, y1=yearlyl_open, y2=yearlyl_open, color=YearlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var yearlyl_label = label.new(x=yearlyl_limit_right, y=yearlyl_open, text=cyltext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(yearlyl_line, yearlyl_time)
- line.set_x2(yearlyl_line, yearlyl_limit_right)
- line.set_y1(yearlyl_line, yearlyl_open)
- line.set_y2(yearlyl_line, yearlyl_open)
- label.set_x(yearlyl_label, yearlyl_limit_right)
- label.set_y(yearlyl_label, yearlyl_open)
- label.set_text(yearlyl_label, cyltext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, yearlyl_open, yearlyl_label, YearlyColor)
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY HIGH HIGH HIGH
- if is_yearlyrange_enabled
- yearlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- yearlyh_time := get_limit_right(radistance)
- yearlyh_time
- var yearlyh_line = line.new(x1=yearlyh_time, x2=yearlyh_limit_right, y1=yearlyh_open, y2=yearlyh_open, color=YearlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var yearlyh_label = label.new(x=yearlyh_limit_right, y=yearlyh_open, text=cyhtext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(yearlyh_line, yearlyh_time)
- line.set_x2(yearlyh_line, yearlyh_limit_right)
- line.set_y1(yearlyh_line, yearlyh_open)
- line.set_y2(yearlyh_line, yearlyh_open)
- label.set_x(yearlyh_label, yearlyh_limit_right)
- label.set_y(yearlyh_label, yearlyh_open)
- label.set_text(yearlyh_label, cyhtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, yearlyh_open, yearlyh_label, YearlyColor)
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY OPEN
- if is_yearly_enabled
- yearly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- yearly_time := get_limit_right(radistance)
- yearly_time
- var yearly_line = line.new(x1=yearly_time, x2=yearly_limit_right, y1=yearly_open, y2=yearly_open, color=YearlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var yearly_label = label.new(x=yearly_limit_right, y=yearly_open, text=yotext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(yearly_line, yearly_time)
- line.set_x2(yearly_line, yearly_limit_right)
- line.set_y1(yearly_line, yearly_open)
- line.set_y2(yearly_line, yearly_open)
- label.set_x(yearly_label, yearly_limit_right)
- label.set_y(yearly_label, yearly_open)
- label.set_text(yearly_label, yotext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, yearly_open, yearly_label, YearlyColor)
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////// yearly MID
- if is_yearly_mid
- yearlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- yearlym_time = yearlyh_time
- yearlym_open = (yearlyl_open + yearlyh_open) / 2
- if displayStyle == 'Right Anchored'
- yearlym_time := get_limit_right(radistance)
- yearlym_time
- var yearlym_line = line.new(x1=yearlym_time, x2=yearlym_limit_right, y1=yearlym_open, y2=yearlym_open, color=YearlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var yearlym_label = label.new(x=yearlym_limit_right, y=yearlym_open, text=cymtext, style=DEFAULT_LABEL_STYLE, textcolor=YearlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(yearlym_line, yearlym_time)
- line.set_x2(yearlym_line, yearlym_limit_right)
- line.set_y1(yearlym_line, yearlym_open)
- line.set_y2(yearlym_line, yearlym_open)
- label.set_x(yearlym_label, yearlym_limit_right)
- label.set_y(yearlym_label, yearlym_open)
- label.set_text(yearlym_label, cymtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, yearlym_open, yearlym_label, YearlyColor)
- ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY OPEN
- if is_quarterly_enabled
- quarterly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- quarterly_time := get_limit_right(radistance)
- quarterly_time
- var quarterly_line = line.new(x1=quarterly_time, x2=quarterly_limit_right, y1=quarterly_open, y2=quarterly_open, color=quarterlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var quarterly_label = label.new(x=quarterly_limit_right, y=quarterly_open, text=qotext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(quarterly_line, quarterly_time)
- line.set_x2(quarterly_line, quarterly_limit_right)
- line.set_y1(quarterly_line, quarterly_open)
- line.set_y2(quarterly_line, quarterly_open)
- label.set_x(quarterly_label, quarterly_limit_right)
- label.set_y(quarterly_label, quarterly_open)
- label.set_text(quarterly_label, qotext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, quarterly_open, quarterly_label, quarterlyColor)
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY High
- if is_quarterlyrange_enabled
- quarterlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- quarterlyh_time := get_limit_right(radistance)
- quarterlyh_time
- var quarterlyh_line = line.new(x1=quarterlyh_time, x2=quarterlyh_limit_right, y1=quarterlyh_open, y2=quarterlyh_open, color=quarterlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var quarterlyh_label = label.new(x=quarterlyh_limit_right, y=quarterlyh_open, text=pqhtext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(quarterlyh_line, quarterlyh_time)
- line.set_x2(quarterlyh_line, quarterlyh_limit_right)
- line.set_y1(quarterlyh_line, quarterlyh_open)
- line.set_y2(quarterlyh_line, quarterlyh_open)
- label.set_x(quarterlyh_label, quarterlyh_limit_right)
- label.set_y(quarterlyh_label, quarterlyh_open)
- label.set_text(quarterlyh_label, pqhtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, quarterlyh_open, quarterlyh_label, quarterlyColor)
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY Low
- if is_quarterlyrange_enabled
- quarterlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- quarterlyl_time := get_limit_right(radistance)
- quarterlyl_time
- var quarterlyl_line = line.new(x1=quarterlyl_time, x2=quarterlyl_limit_right, y1=quarterlyl_open, y2=quarterlyl_open, color=quarterlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var quarterlyl_label = label.new(x=quarterlyl_limit_right, y=quarterlyl_open, text=pqltext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(quarterlyl_line, quarterlyl_time)
- line.set_x2(quarterlyl_line, quarterlyl_limit_right)
- line.set_y1(quarterlyl_line, quarterlyl_open)
- line.set_y2(quarterlyl_line, quarterlyl_open)
- label.set_x(quarterlyl_label, quarterlyl_limit_right)
- label.set_y(quarterlyl_label, quarterlyl_open)
- label.set_text(quarterlyl_label, pqltext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, quarterlyl_open, quarterlyl_label, quarterlyColor)
- //////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY MID
- if is_quarterly_mid
- quarterlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- quarterlym_time = quarterlyh_time
- quarterlym_open = (quarterlyl_open + quarterlyh_open) / 2
- if displayStyle == 'Right Anchored'
- quarterlym_time := get_limit_right(radistance)
- quarterlym_time
- var quarterlym_line = line.new(x1=quarterlym_time, x2=quarterlym_limit_right, y1=quarterlym_open, y2=quarterlym_open, color=quarterlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var quarterlym_label = label.new(x=quarterlym_limit_right, y=quarterlym_open, text=pqmtext, style=DEFAULT_LABEL_STYLE, textcolor=quarterlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(quarterlym_line, quarterlym_time)
- line.set_x2(quarterlym_line, quarterlym_limit_right)
- line.set_y1(quarterlym_line, quarterlym_open)
- line.set_y2(quarterlym_line, quarterlym_open)
- label.set_x(quarterlym_label, quarterlym_limit_right)
- label.set_y(quarterlym_label, quarterlym_open)
- label.set_text(quarterlym_label, pqmtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, quarterlym_open, quarterlym_label, quarterlyColor)
- ////////////////////////////////////////////////////////////////////////////////// Monthly LOW LOW LOW
- if is_monthlyrange_enabled
- monthlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- monthlyl_time := get_limit_right(radistance)
- monthlyl_time
- var monthlyl_line = line.new(x1=monthlyl_time, x2=monthlyl_limit_right, y1=monthlyl_open, y2=monthlyl_open, color=MonthlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var monthlyl_label = label.new(x=monthlyl_limit_right, y=monthlyl_open, text=pmltext, style=DEFAULT_LABEL_STYLE, textcolor=MonthlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(monthlyl_line, monthlyl_time)
- line.set_x2(monthlyl_line, monthlyl_limit_right)
- line.set_y1(monthlyl_line, monthlyl_open)
- line.set_y2(monthlyl_line, monthlyl_open)
- label.set_x(monthlyl_label, monthlyl_limit_right)
- label.set_y(monthlyl_label, monthlyl_open)
- label.set_text(monthlyl_label, pmltext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, monthlyl_open, monthlyl_label, MonthlyColor)
- // the weekly open can be the daily open too (monday)
- // only the weekly will be draw, in these case we update its label
- //////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////// MONTHLY HIGH HIGH HIGH
- if is_monthlyrange_enabled
- monthlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- monthlyh_time := get_limit_right(radistance)
- monthlyh_time
- var monthlyh_line = line.new(x1=monthlyh_time, x2=monthlyh_limit_right, y1=monthlyh_open, y2=monthlyh_open, color=MonthlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var monthlyh_label = label.new(x=monthlyh_limit_right, y=monthlyh_open, text=pmhtext, style=DEFAULT_LABEL_STYLE, textcolor=MonthlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(monthlyh_line, monthlyl_time)
- line.set_x2(monthlyh_line, monthlyh_limit_right)
- line.set_y1(monthlyh_line, monthlyh_open)
- line.set_y2(monthlyh_line, monthlyh_open)
- label.set_x(monthlyh_label, monthlyh_limit_right)
- label.set_y(monthlyh_label, monthlyh_open)
- label.set_text(monthlyh_label, pmhtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, monthlyh_open, monthlyh_label, MonthlyColor)
- // the weekly open can be the daily open too (monday)
- // only the weekly will be draw, in these case we update its label
- //////////////////////////////////////////////////////////////////////////////// MONTHLY MID
- if is_monthly_mid
- monthlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- monthlym_time = monthlyh_time
- monthlym_open = (monthlyl_open + monthlyh_open) / 2
- if displayStyle == 'Right Anchored'
- monthlym_time := get_limit_right(radistance)
- monthlym_time
- var monthlym_line = line.new(x1=monthlym_time, x2=monthlym_limit_right, y1=monthlym_open, y2=monthlym_open, color=MonthlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var monthlym_label = label.new(x=monthlym_limit_right, y=monthlym_open, text=pmmtext, style=DEFAULT_LABEL_STYLE, textcolor=MonthlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(monthlym_line, monthlym_time)
- line.set_x2(monthlym_line, monthlym_limit_right)
- line.set_y1(monthlym_line, monthlym_open)
- line.set_y2(monthlym_line, monthlym_open)
- label.set_x(monthlym_label, monthlym_limit_right)
- label.set_y(monthlym_label, monthlym_open)
- label.set_text(monthlym_label, pmmtext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, monthlym_open, monthlym_label, MonthlyColor)
- //////////////////////////////////////////////////////////////////////////////////
- if is_monthly_enabled
- monthly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
- if displayStyle == 'Right Anchored'
- monthly_time := get_limit_right(radistance)
- monthly_time
- var monthlyLine = line.new(x1=monthly_time, x2=monthly_limit_right, y1=monthly_open, y2=monthly_open, color=MonthlyColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
- var monthlyLabel = label.new(x=monthly_limit_right, y=monthly_open, text=motext, style=DEFAULT_LABEL_STYLE, textcolor=MonthlyColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
- line.set_x1(monthlyLine, monthly_time)
- line.set_x2(monthlyLine, monthly_limit_right)
- line.set_y1(monthlyLine, monthly_open)
- line.set_y2(monthlyLine, monthly_open)
- label.set_x(monthlyLabel, monthly_limit_right)
- label.set_y(monthlyLabel, monthly_open)
- label.set_text(monthlyLabel, motext)
- if mergebool
- f_LevelMerge(pricearray, labelarray, monthly_open, monthlyLabel, MonthlyColor)
- /////////////////////////////////////////////////////////////////////////////
- // the monthly open can be the weekly open (monday 1st) and/or daily open too
- // only the monthly will be draw, in these case we update its label
- // if is_monthly_open
- // if can_show_daily
- // label.set_text(monthlyLabel, "DO / MO ")
- // if is_weekly_open
- // if can_show_weekly
- // label.set_text(monthlyLabel, "WO / MO ")
- // if can_show_daily and can_show_weekly
- // label.set_text(monthlyLabel, "DO / WO / MO ")
- // the start of the line is drew from the first week of the month
- // if the first day of the weekly candle (monday) is the 2nd of the month
- // we fix the start of the line position on the Prev weekly candle
- if timeframe.isweekly and dayofweek(monthly_time) != dayofweek.monday
- line.set_x1(monthlyLine, monthly_time - (weekly_time - weekly_time[1]))
Advertisement
Add Comment
Please, Sign In to add comment