xmd79

OFJ

Nov 29th, 2022
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 70.45 KB | None | 0 0
  1. //Credit:// ©jonico daily session break | ©boitoki session boxes
  2. //Volumebars ©truece
  3. // YESTERDAY HI/LO, LASK WK HI/LO
  4. // Original pattern formation by plasmapug, rise retrace continuation to the upside by infernix, peshocore and xtech5192
  5. // Range daily/weekly Hi/Lo added with research contributions from xtech5192
  6. // 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
  7. // source code you to name those scripts using "Traders Reality", "Pattern Watchers" or any other name that relates to Traders Reality in any way.
  8.  
  9. //@version=5
  10. indicator('OFJ', overlay=true, max_bars_back=300,max_boxes_count=500, max_lines_count=500, max_labels_count=500, scale=scale.none)
  11.  
  12. ////////
  13. h = input.int(defval=19, title='Hour', maxval=23, minval=0)
  14. m = input.int(defval=0, title='Minute', maxval=59, minval=0)
  15. c = input(defval=color.black, title='color')
  16.  
  17. isHour = hour == h
  18. isMinute = minute == m
  19.  
  20. if isHour and isMinute
  21. 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)
  22.  
  23. // Config
  24. label_offset_input = input.int(group='Label offsets', title='General', defval=5, inline='labeloffset1')
  25.  
  26.  
  27. /// market boxes and daily open only on intraday
  28. bool show = timeframe.isminutes and timeframe.multiplier <= 60 and timeframe.multiplier >= 0
  29. time_now_exchange = timestamp(year, month, dayofmonth, hour, minute, second)
  30.  
  31.  
  32.  
  33. string rectStyle = input.string(group='Market sessions', defval='Dashed', title='Line style of Market Session hi/lo line', options=['Dashed', 'Solid'])
  34. sessLineStyle = line.style_dashed
  35. bool show_markets = input.bool(true, group='Market sessions', title='Show Market Sessions?', tooltip='Turn on or off all market sessions') and show
  36. 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
  37. string weekend_sessions = ':1234567'
  38. string no_weekend_sessions = ':23456'
  39.  
  40. 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
  41. 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
  42. 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
  43. string sess1Label = input.string(group='Market session: London (0800-1630 UTC+0) - DST Aware', defval='London', title='Name:', inline='session1style')
  44. 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')
  45. 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')
  46. 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.')
  47. sess1Time = show_markets_weekends ? sess1TimeX + weekend_sessions : sess1TimeX + no_weekend_sessions
  48.  
  49.  
  50. 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
  51. 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
  52. 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
  53. string sess2Label = input.string(group='Market session: New York (1430-2100 UTC+0) - DST Aware', defval='NewYork', title='Name:', inline='session2style')
  54. 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')
  55. 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')
  56. 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.')
  57. sess2Time = show_markets_weekends ? sess2TimeX + weekend_sessions : sess2TimeX + no_weekend_sessions
  58.  
  59.  
  60. 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
  61. 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
  62. 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
  63. string sess3Label = input.string(group='Market session: Tokyo (0000-0600 UTC+0) - DST Aware', defval='Tokyo', title='Name:', inline='session3style')
  64. 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')
  65. 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')
  66. 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.')
  67. sess3Time = show_markets_weekends ? sess3TimeX + weekend_sessions : sess3TimeX + no_weekend_sessions
  68.  
  69.  
  70. 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
  71. 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
  72. 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
  73. string sess4Label = input.string(group='Market session: Hong Kong (0130-0800 UTC+0) - DST Aware', defval='HongKong', title='Name:', inline='session4style')
  74. 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')
  75. 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')
  76. 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.')
  77. sess4Time = show_markets_weekends ? sess4TimeX + weekend_sessions : sess4TimeX + no_weekend_sessions
  78.  
  79. 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
  80. 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
  81. 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
  82. string sess5Label = input.string(group='Market session: Sydney (NZX+ASX 2200-0600 UTC+0) - DST Aware', defval='Sydney', title='Name:', inline='session5style')
  83. 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')
  84. 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')
  85. 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.')
  86. sess5Time = show_markets_weekends ? sess5TimeX + weekend_sessions : sess5TimeX + no_weekend_sessions
  87.  
  88.  
  89.  
  90. 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
  91. 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
  92. 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
  93. string sess8Label = input.string(group='Market session: Frankfurt (0700-1630 UTC+0) - DST Aware', defval='Frankfurt', title='Name:', inline='session8style')
  94. 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')
  95. 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')
  96. 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.')
  97. sess8Time = show_markets_weekends ? sess8TimeX + weekend_sessions : sess8TimeX + no_weekend_sessions
  98.  
  99.  
  100. //Non repainting security
  101. f_security(_symbol, _res, _src, _repaint) =>
  102. request.security(_symbol, _res, _src[_repaint ? 0 : barstate.isrealtime ? 1 : 0])[_repaint ? 0 : barstate.isrealtime ? 0 : 1]
  103.  
  104.  
  105.  
  106. // Basic vars (needed in functions)
  107.  
  108. // Only render intraday
  109. validTimeFrame = timeframe.isintraday == true
  110.  
  111. // If above the 5 minute, we start drawing yesterday. below, we start today
  112. levelsstart = timeframe.isseconds == true or timeframe.isminutes == true and timeframe.multiplier < 5 ? time('D') : time('D') - 86400 * 1000
  113. //levelsstartbar = ta.barssince(levelsstart)
  114.  
  115.  
  116. // Functions
  117. // new_bar: check if we're on a new bar within the session in a given resolution
  118. new_bar(res) =>
  119. ta.change(time(res)) != 0
  120.  
  121. label_x_offset = time_close + label_offset_input * timeframe.multiplier * 60 * 1000
  122.  
  123. //Right_Label
  124. r_label(ry, rtext, rstyle, rcolor, valid) =>
  125. var label rLabel = na
  126. if valid and barstate.isrealtime
  127. rLabel := label.new(x=label_x_offset, y=ry, text=rtext, xloc=xloc.bar_time, style=rstyle, textcolor=rcolor, textalign=text.align_right)
  128. label.delete(rLabel[1])
  129. rLabel
  130.  
  131. //Right_Label
  132. r_label_offset(ry, rtext, rstyle, rcolor, valid, labelOffset) =>
  133. if valid and barstate.isrealtime
  134. rLabel = label.new(x=labelOffset, y=ry, text=rtext, xloc=xloc.bar_time, style=rstyle, textcolor=rcolor, textalign=text.align_right)
  135. label.delete(rLabel[1])
  136.  
  137. draw_line(x_series, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, xLabelOffset) =>
  138. var line x_line = na
  139.  
  140. if validTimeFrame and new_bar(res) //and barstate.isnew
  141. x_line := line.new(bar_index, x_series, bar_index+1, x_series, extend=xExtend, color=xColor, style=xStyle, width=xWidth)
  142. line.delete(x_line[1])
  143.  
  144. if not na(x_line) and not new_bar(res)//and line.get_x2(x_line) != bar_index
  145. line.set_x2(x_line, bar_index)
  146. line.set_y1(x_line,x_series)
  147. line.set_y2(x_line,x_series)
  148.  
  149. if isLabelValid //showADRLabels and validTimeFrame
  150. x_label = label.new(xLabelOffset, x_series, tag, xloc=xloc.bar_time, style=label.style_none, textcolor=xColor)
  151. label.delete(x_label[1])
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. //*****************
  161. // Market sessions
  162. //*****************
  163. splitSessionString(sessXTime) =>
  164. //session stirng looks like this: 0000-0000:1234567 ie start time, end time, day of the week
  165. //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
  166.  
  167. //string times contains "0000-2300" as an example
  168. string times = array.get(str.split(sessXTime, ':'), 0)
  169.  
  170. //string startTime contains "0000"
  171. string startTime = array.get(str.split(times, '-'), 0)
  172. //string endTime contains "2300"
  173. string endTime = array.get(str.split(times, '-'), 1)
  174.  
  175. //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
  176. string[] startTimeChars = str.split(startTime, '')
  177. string[] endTimeChars = str.split(endTime, '')
  178.  
  179. //so now startHour contains 00 and start min contains 00
  180. string startHour = array.get(startTimeChars, 0) + array.get(startTimeChars, 1)
  181. string startMin = array.get(startTimeChars, 2) + array.get(startTimeChars, 3)
  182.  
  183. //so now endHour contains 23 and end min contains 00
  184. string endHour = array.get(endTimeChars, 0) + array.get(endTimeChars, 1)
  185. string endMin = array.get(endTimeChars, 2) + array.get(endTimeChars, 3)
  186. [startHour, startMin, endHour, endMin]
  187.  
  188. calc_session_startend(sessXTime, gmt) =>
  189. [startHour, startMin, endHour, endMin] = splitSessionString(sessXTime)
  190. targetstartTimeX = timestamp(gmt, year, month, dayofmonth, math.round(str.tonumber(startHour)), math.round(str.tonumber(startMin)), 00)
  191. targetendTimeX = timestamp(gmt, year, month, dayofmonth, math.round(str.tonumber(endHour)), math.round(str.tonumber(endMin)), 00)
  192. time_now = timestamp(year, month, dayofmonth, hour, minute, 00)
  193. midnight_exchange = timestamp(year, month, dayofmonth, 00, 00, 00)
  194.  
  195.  
  196. //if start hour is greater than end hour we are dealing with a session that starts towards the end of one day
  197. //and ends the next day. ie advance the end time by 24 hours - its the next day
  198. bool adjusted = false
  199. if gmt == 'GMT+0'
  200. if math.round(str.tonumber(startHour)) > math.round(str.tonumber(endHour))
  201. if time_now - targetstartTimeX >= 0
  202. targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
  203. adjusted := true
  204. targetendTimeX
  205. if gmt == 'GMT+1'
  206. if math.round(str.tonumber(startHour)) == 0
  207. startHour := '24'
  208. if math.round(str.tonumber(endHour)) == 0
  209. endHour := '24'
  210. if math.round(str.tonumber(startHour))-1 > math.round(str.tonumber(endHour))-1
  211. if time_now - targetstartTimeX >= 0
  212. targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
  213. adjusted := true
  214. targetendTimeX
  215.  
  216. //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
  217. //we still need to adjust the end time.
  218.  
  219. if targetstartTimeX < midnight_exchange and midnight_exchange < targetendTimeX and not adjusted
  220. targetendTimeX := targetendTimeX + 24 * 60 * 60 * 1000
  221. targetendTimeX
  222.  
  223. [targetstartTimeX,targetendTimeX]
  224.  
  225.  
  226. draw_open_range(sessXTime, sessXcol, show_orX, gmt)=>
  227. if show_orX
  228. // Initialize variables on bar zero only, so they preserve their values across bars.
  229. var hi = float(na)
  230. var lo = float(na)
  231. var box hiLoBox = na
  232. // Detect changes in timeframe.
  233. session = time(timeframe.period, sessXTime, gmt)
  234. bool newTF = session and not session[1]
  235. if newTF
  236. // New bar in higher timeframe; reset values and create new lines and box.
  237. [targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime, gmt)
  238. sessionDuration = math.round(math.abs(time - targetendTimeX)/(timeframe.multiplier*60*1000))
  239.  
  240. hi := high
  241. lo := low
  242. hiLoBox := box.new(bar_index, hi, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, lo, border_color = na, bgcolor = sessXcol)
  243. int(na)
  244. else
  245. if timeframe.multiplier == 1 and (na(session[1]) and not na(session) or session[1] < session)
  246. box.set_right(hiLoBox, bar_index+1)
  247. int(na)
  248. draw_session_hilo(sessXTime, show_rectangleX, show_labelX, sessXcolLabel, sessXLabel, gmt)=>
  249. if show_rectangleX
  250. // Initialize variables on bar zero only, so they preserve their values across bars.
  251. var hi = float(0)
  252. var lo = float(10000000000.0)
  253.  
  254. var line line_t = na
  255. var line line_b = na
  256. var label line_label = na
  257. // var box hiLoBox = na
  258. // Detect changes in timeframe.
  259. session = time(timeframe.period, sessXTime, gmt)
  260. sessLineStyleX = rectStyle == 'Solid' ? line.style_solid : line.style_dashed
  261. bool newTF = session and not session[1]
  262. hi := newTF ? high : session ? math.max(high, hi[1]) : hi[1]
  263. lo := newTF ? low : session ? math.min(low, lo[1]) : lo[1]
  264.  
  265. if newTF
  266. beginIndex = bar_index
  267. [targetstartTimeX,targetendTimeX] = calc_session_startend(sessXTime, gmt)
  268. sessionDuration = math.round(math.abs(time - targetendTimeX)/(timeframe.multiplier*60*1000))
  269.  
  270. line_t := line.new(beginIndex, hi, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, hi, xloc=xloc.bar_index, style=sessLineStyleX, color=sessXcolLabel)
  271. line_b := line.new(beginIndex, lo, timeframe.multiplier == 1? bar_index : bar_index+sessionDuration, lo, xloc=xloc.bar_index, style=sessLineStyleX, color=sessXcolLabel)
  272. line.delete(line_t[1])
  273. line.delete(line_b[1])
  274. if show_labelX
  275. line_label := label.new(beginIndex, hi, sessXLabel, xloc=xloc.bar_index, textcolor=sessXcolLabel, style=label.style_none, size=size.normal, textalign=text.align_right)
  276. label.delete(line_label[1])
  277.  
  278. int(na)
  279. else
  280. if na(session[1]) and not na(session) or session[1] < session
  281. if timeframe.multiplier == 1
  282. line.set_x2(line_t,bar_index+1)
  283. line.set_x2(line_b,bar_index+1)
  284. line.set_y1(line_t,hi)
  285. line.set_y2(line_t,hi)
  286. line.set_y1(line_b,lo)
  287. line.set_y2(line_b,lo)
  288. if show_labelX and not na(line_label)
  289. label.set_y(line_label, hi)
  290. int(na)
  291.  
  292.  
  293.  
  294.  
  295. //*****************************//
  296. // Daylight Savings Time Flags //
  297. //*****************************//
  298.  
  299. int previousSunday = dayofmonth - dayofweek + 1
  300. bool nyDST = na
  301. bool ukDST = na
  302. bool sydDST = na
  303.  
  304. if month < 3 or month > 11
  305. nyDST := false
  306. ukDST := false
  307. sydDST := true
  308. else if month > 4 and month < 10
  309. nyDST := true
  310. ukDST := true
  311. sydDST := false
  312. else if month == 3
  313. nyDST := previousSunday >= 8
  314. ukDST := previousSunday >= 24
  315. sydDST := true
  316. else if month == 4
  317. nyDST := true
  318. ukDST := true
  319. sydDST := previousSunday <= 0
  320. else if month == 10
  321. nyDST := true
  322. ukDST := previousSunday <= 24
  323. sydDST := previousSunday >= 0
  324. else // month == 11
  325. nyDST := previousSunday <= 0
  326. ukDST := false
  327. sydDST := true
  328.  
  329.  
  330.  
  331.  
  332. if ukDST
  333. draw_open_range(sess1Time,sess1col,show_or1,'GMT+1')
  334. draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel, sess1Label, 'GMT+1')
  335. else
  336. draw_open_range(sess1Time,sess1col,show_or1,'GMT+0')
  337. draw_session_hilo(sess1Time, show_rectangle1, show_label1, sess1colLabel, sess1Label, 'GMT+0')
  338.  
  339. if nyDST
  340. draw_open_range(sess2Time,sess2col,show_or2,'GMT+1')
  341. draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel, sess2Label, 'GMT+1')
  342. else
  343. draw_open_range(sess2Time,sess2col,show_or2,'GMT+0')
  344. draw_session_hilo(sess2Time, show_rectangle2, show_label2, sess2colLabel, sess2Label, 'GMT+0')
  345.  
  346. // Tokyo
  347. draw_open_range(sess3Time,sess3col,show_or3,'GMT+0')
  348. draw_session_hilo(sess3Time, show_rectangle3, show_label3, sess3colLabel, sess3Label, 'GMT+0')
  349.  
  350. // Hong Kong
  351. draw_open_range(sess4Time,sess4col,show_or4,'GMT+0')
  352. draw_session_hilo(sess4Time, show_rectangle4, show_label4, sess4colLabel, sess4Label, 'GMT+0')
  353.  
  354. if sydDST
  355. draw_open_range(sess5Time,sess5col,show_or5,'GMT+1')
  356. draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel, sess5Label, 'GMT+1')
  357. else
  358. draw_open_range(sess5Time,sess5col,show_or5,'GMT+0')
  359. draw_session_hilo(sess5Time, show_rectangle5, show_label5, sess5colLabel, sess5Label, 'GMT+0')
  360.  
  361.  
  362. //becuase frankfurt changes with london
  363. if ukDST
  364. draw_open_range(sess8Time,sess8col,show_or8,'GMT+1')
  365. draw_session_hilo(sess8Time, show_rectangle8, show_label8, sess8colLabel, sess8Label, 'GMT+1')
  366. else
  367. draw_open_range(sess8Time,sess8col,show_or8,'GMT+0')
  368. draw_session_hilo(sess8Time, show_rectangle8, show_label8, sess8colLabel, sess8Label, 'GMT+0')
  369.  
  370.  
  371. //@version=5
  372. //@mrSebastienC thank you for doing the base code
  373. //Added additional levels for convienience sake.
  374.  
  375. //35 works
  376. displayStyle = input.string(defval='Standard', title='Display Style', options=['Standard', 'Right Anchored'], inline='Display')
  377. mergebool = input.bool(defval=true, title='Merge Levels?', inline='Display')
  378. distanceright = input.int(defval=30, title='Distance', minval=5, maxval=500, inline='Dist')
  379. radistance = input.int(defval=250, title='Anchor Distance', minval=5, maxval=500, inline='Dist')
  380. labelsize = input.string(defval='Medium', title='Text Size', options=['Small', 'Medium', 'Large'])
  381. linesize = input.string(defval='Small', title='Line Width', options=['Small', 'Medium', 'Large'], inline='Line')
  382. linestyle = input.string(defval='Solid', title='Line Style', options=['Solid', 'Dashed', 'Dotted'], inline='Line')
  383.  
  384.  
  385.  
  386.  
  387. GlobalTextType = input.bool(defval=true, title='Global Text ShortHand', tooltip='Enable for shorthand text on all text')
  388. var globalcoloring = input.bool(defval=false, title='Global Coloring', tooltip='Enable for all color controls via one color', inline='GC')
  389. GlobalColor = input.color(title='', defval=#03abff, inline='GC')
  390. //var show_tails = input(defval = false, title = "Always Show", type = input.bool)
  391.  
  392.  
  393. [daily_time, daily_open] = request.security(syminfo.tickerid, 'D', [time, open], lookahead=barmerge.lookahead_on)
  394. [dailyh_time, dailyh_open] = request.security(syminfo.tickerid, 'D', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  395. [dailyl_time, dailyl_open] = request.security(syminfo.tickerid, 'D', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  396.  
  397. cdailyh_open = request.security(syminfo.tickerid, 'D', high, lookahead=barmerge.lookahead_on)
  398. cdailyl_open = request.security(syminfo.tickerid, 'D', low, lookahead=barmerge.lookahead_on)
  399. var monday_time = time
  400. var monday_high = high
  401. var monday_low = low
  402.  
  403. [weekly_time, weekly_open] = request.security(syminfo.tickerid, 'W', [time, open], lookahead=barmerge.lookahead_on)
  404. [weeklyh_time, weeklyh_open] = request.security(syminfo.tickerid, 'W', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  405. [weeklyl_time, weeklyl_open] = request.security(syminfo.tickerid, 'W', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  406.  
  407.  
  408. [monthly_time, monthly_open] = request.security(syminfo.tickerid, 'M', [time, open], lookahead=barmerge.lookahead_on)
  409. [monthlyh_time, monthlyh_open] = request.security(syminfo.tickerid, 'M', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  410. [monthlyl_time, monthlyl_open] = request.security(syminfo.tickerid, 'M', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  411.  
  412.  
  413. [quarterly_time, quarterly_open] = request.security(syminfo.tickerid, '3M', [time, open], lookahead=barmerge.lookahead_on)
  414. [quarterlyh_time, quarterlyh_open] = request.security(syminfo.tickerid, '3M', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  415. [quarterlyl_time, quarterlyl_open] = request.security(syminfo.tickerid, '3M', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  416.  
  417.  
  418. [yearly_time, yearly_open] = request.security(syminfo.tickerid, '12M', [time, open], lookahead=barmerge.lookahead_on)
  419. [yearlyh_time, yearlyh_open] = request.security(syminfo.tickerid, '12M', [time, high], lookahead=barmerge.lookahead_on)
  420. [yearlyl_time, yearlyl_open] = request.security(syminfo.tickerid, '12M', [time, low], lookahead=barmerge.lookahead_on)
  421.  
  422.  
  423. [intra_time, intra_open] = request.security(syminfo.tickerid, '240', [time, open], lookahead=barmerge.lookahead_on)
  424. [intrah_time, intrah_open] = request.security(syminfo.tickerid, '240', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  425. [intral_time, intral_open] = request.security(syminfo.tickerid, '240', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  426.  
  427. //------------------------------ Inputs -------------------------------
  428.  
  429.  
  430.  
  431. var is_intra_enabled = input.bool(defval=false, title='Open', group='4H', inline='4H')
  432. var is_intrarange_enabled = input.bool(defval=false, title='Prev H/L', group='4H', inline='4H')
  433. var is_intram_enabled = input.bool(defval=false, title='Prev Mid', group='4H', inline='4H')
  434. IntraTextType = input.bool(defval=false, title='ShortHand', group='4H', inline='4Hsh')
  435.  
  436. var is_daily_enabled = input.bool(defval=true, title='Open', group='Daily', inline='Daily')
  437. var is_dailyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Daily', inline='Daily')
  438. var is_dailym_enabled = input.bool(defval=false, title='Prev Mid', group='Daily', inline='Daily')
  439. DailyTextType = input.bool(defval=false, title='ShortHand', group='Daily', inline='Dailysh')
  440.  
  441. var is_monday_enabled = input.bool(defval=true, title='Range', group='Monday Range', inline='Monday')
  442. var is_monday_mid = input.bool(defval=false, title='Mid', group='Monday Range', inline='Monday')
  443. var untested_monday = false
  444. MondayTextType = input.bool(defval=false, title='ShortHand', group='Monday Range', inline='Mondaysh')
  445.  
  446. var is_weekly_enabled = input.bool(defval=true, title='Open', group='Weekly', inline='Weekly')
  447. var is_weeklyrange_enabled = input.bool(defval=true, title='Prev H/L', group='Weekly', inline='Weekly')
  448. var is_weekly_mid = input.bool(defval=true, title='Prev Mid', group='Weekly', inline='Weekly')
  449. WeeklyTextType = input.bool(defval=false, title='ShortHand', group='Weekly', inline='Weeklysh')
  450.  
  451. var is_monthly_enabled = input.bool(defval=true, title='Open', group='Monthly', inline='Monthly')
  452. var is_monthlyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Monthly', inline='Monthly')
  453. var is_monthly_mid = input.bool(defval=false, title='Prev Mid', group='Monthly', inline='Monthly')
  454. MonthlyTextType = input.bool(defval=false, title='ShortHand', group='Monthly', inline='Monthlysh')
  455.  
  456. var is_quarterly_enabled = input.bool(defval=false, title='Open', group='Quarterly', inline='Quarterly')
  457. var is_quarterlyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Quarterly', inline='Quarterly')
  458. var is_quarterly_mid = input.bool(defval=false, title='Prev Mid', group='Quarterly', inline='Quarterly')
  459. QuarterlyTextType = input.bool(defval=false, title='ShortHand', group='Quarterly', inline='Quarterlysh')
  460.  
  461. var is_yearly_enabled = input.bool(defval=false, title='Open', group='Yearly', inline='Yearly')
  462. var is_yearlyrange_enabled = input.bool(defval=false, title='Current H/L', group='Yearly', inline='Yearly')
  463. var is_yearly_mid = input.bool(defval=false, title='Mid', group='Yearly', inline='Yearly')
  464. YearlyTextType = input.bool(defval=false, title='ShortHand', group='Yearly', inline='Yearlysh')
  465.  
  466.  
  467.  
  468.  
  469. DailyColor = input.color(title='', defval=#08bcd4, group='Daily', inline='Dailysh')
  470. MondayColor = input.color(title='', defval=color.white, group='Monday Range', inline='Mondaysh')
  471. WeeklyColor = input.color(title='', defval=#fffcbc, group='Weekly', inline='Weeklysh')
  472. MonthlyColor = input.color(title='', defval=#08d48c, group='Monthly', inline='Monthlysh')
  473. YearlyColor = input.color(title='', defval=color.red, group='Yearly', inline='Yearlysh')
  474. quarterlyColor = input.color(title='', defval=color.red, group='Quarterly', inline='Quarterlysh')
  475. IntraColor = input.color(title='', defval=color.orange, group='4H', inline='4Hsh')
  476. var pdhtext = GlobalTextType or DailyTextType ? 'PDH' : 'Prev Day High'
  477. var pdltext = GlobalTextType or DailyTextType ? 'PDL' : 'Prev Day Low'
  478. var dotext = GlobalTextType or DailyTextType ? 'DO' : 'Daily Open'
  479. var pdmtext = GlobalTextType or DailyTextType ? 'PDM' : 'Prev Day Mid'
  480.  
  481. var pwhtext = GlobalTextType or WeeklyTextType ? 'PWH' : 'Prev Week High'
  482. var pwltext = GlobalTextType or WeeklyTextType ? 'PWL' : 'Prev Week Low'
  483. var wotext = GlobalTextType or WeeklyTextType ? 'WO' : 'Weekly Open'
  484. var pwmtext = GlobalTextType or WeeklyTextType ? 'PWM' : 'Prev Week Mid'
  485.  
  486. var pmhtext = GlobalTextType or MonthlyTextType ? 'PMH' : 'Prev Month High'
  487. var pmltext = GlobalTextType or MonthlyTextType ? 'PML' : 'Prev Month Low'
  488. var motext = GlobalTextType or MonthlyTextType ? 'MO' : 'Monthly Open'
  489. var pmmtext = GlobalTextType or MonthlyTextType ? 'PMM' : 'Prev Month Mid'
  490.  
  491. var pqhtext = GlobalTextType or QuarterlyTextType ? 'PQH' : 'Prev Quarter High'
  492. var pqltext = GlobalTextType or QuarterlyTextType ? 'PQL' : 'Prev Quarter Low'
  493. var qotext = GlobalTextType or QuarterlyTextType ? 'QO' : 'Quarterly Open'
  494. var pqmtext = GlobalTextType or QuarterlyTextType ? 'PQM' : 'Prev Quarter Mid'
  495.  
  496. var cyhtext = GlobalTextType or YearlyTextType ? 'CYH' : 'Current Year High'
  497. var cyltext = GlobalTextType or YearlyTextType ? 'CYL' : 'Current Year Low'
  498. var yotext = GlobalTextType or YearlyTextType ? 'YO' : 'Yearly Open'
  499. var cymtext = GlobalTextType or YearlyTextType ? 'CYM' : 'Current Year Mid'
  500.  
  501. var pihtext = GlobalTextType or IntraTextType ? 'P-4H-H' : 'Prev 4H High'
  502. var piltext = GlobalTextType or IntraTextType ? 'P-4H-L' : 'Prev 4H Low'
  503. var iotext = GlobalTextType or IntraTextType ? '4H-O' : '4H Open'
  504. var pimtext = GlobalTextType or IntraTextType ? 'P-4H-M' : 'Prev 4H Mid'
  505.  
  506. var pmonhtext = GlobalTextType or MondayTextType ? 'MDAY-H' : 'Monday High'
  507. var pmonltext = GlobalTextType or MondayTextType ? 'MDAY-L' : 'Monday Low'
  508. var pmonmtext = GlobalTextType or MondayTextType ? 'MDAY-M' : 'Monday Mid'
  509.  
  510.  
  511. if globalcoloring == true
  512. DailyColor := GlobalColor
  513. MondayColor := GlobalColor
  514. WeeklyColor := GlobalColor
  515. MonthlyColor := GlobalColor
  516. YearlyColor := GlobalColor
  517. quarterlyColor := GlobalColor
  518. IntraColor := GlobalColor
  519. IntraColor
  520.  
  521.  
  522. if weekly_time != weekly_time[1]
  523. untested_monday := false
  524. untested_monday
  525.  
  526. if is_monday_enabled == true and untested_monday == false
  527. untested_monday := true
  528. monday_time := daily_time
  529. monday_high := cdailyh_open
  530. monday_low := cdailyl_open
  531. monday_low
  532.  
  533.  
  534. linewidthint = 1
  535. if linesize == 'Small'
  536. linewidthint := 1
  537. linewidthint
  538. if linesize == 'Medium'
  539. linewidthint := 2
  540. linewidthint
  541. if linesize == 'Large'
  542. linewidthint := 3
  543. linewidthint
  544.  
  545. var DEFAULT_LINE_WIDTH = linewidthint
  546. var DEFAULT_TAIL_WIDTH = linewidthint
  547.  
  548. fontsize = size.small
  549.  
  550. if labelsize == 'Small'
  551. fontsize := size.small
  552. fontsize
  553.  
  554. if labelsize == 'Medium'
  555. fontsize := size.normal
  556. fontsize
  557.  
  558. if labelsize == 'Large'
  559. fontsize := size.large
  560. fontsize
  561.  
  562. linestyles = line.style_solid
  563. if linestyle == 'Dashed'
  564. linestyles := line.style_dashed
  565. linestyles
  566.  
  567. if linestyle == 'Dotted'
  568. linestyles := line.style_dotted
  569. linestyles
  570.  
  571.  
  572.  
  573. var DEFAULT_LABEL_SIZE = fontsize
  574. var DEFAULT_LABEL_STYLE = label.style_none
  575. var DEFAULT_EXTEND_RIGHT = distanceright
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583. //------------------------------ Plotting ------------------------------
  584. var pricearray = array.new_float(0)
  585. var labelarray = array.new_label(0)
  586. f_LevelMerge(pricearray, labelarray, currentprice, currentlabel, currentcolor) =>
  587. if array.includes(pricearray, currentprice)
  588. whichindex = array.indexof(pricearray, currentprice)
  589. labelhold = array.get(labelarray, whichindex)
  590. whichtext = label.get_text(labelhold)
  591.  
  592. label.set_text(labelhold, label.get_text(currentlabel) + ' / ' + whichtext)
  593. label.set_text(currentlabel, '')
  594. label.set_textcolor(labelhold, currentcolor)
  595. else
  596. array.push(pricearray, currentprice)
  597. array.push(labelarray, currentlabel)
  598.  
  599.  
  600. var can_show_daily = is_daily_enabled and timeframe.isintraday
  601. var can_show_weekly = is_weekly_enabled and not timeframe.isweekly and not timeframe.ismonthly
  602. var can_show_monthly = is_monthly_enabled and not timeframe.ismonthly
  603.  
  604. get_limit_right(bars) =>
  605. timenow + (time - time[1]) * bars
  606.  
  607. // the following code doesn't need to be processed on every candle
  608. if barstate.islast
  609. is_weekly_open = dayofweek == dayofweek.monday
  610. is_monthly_open = dayofmonth == 1
  611. can_draw_daily = (is_weekly_enabled ? not is_weekly_open : true) and (is_monthly_enabled ? not is_monthly_open : true)
  612. can_draw_weekly = is_monthly_enabled ? not(is_monthly_open and is_weekly_open) : true
  613. can_draw_intra = is_intra_enabled
  614. can_draw_intrah = is_intrarange_enabled
  615. can_draw_intral = is_intrarange_enabled
  616. can_draw_intram = is_intram_enabled
  617. pricearray := array.new_float(0)
  618. labelarray := array.new_label(0)
  619.  
  620. /////////////////////////////////
  621.  
  622.  
  623. //////////////////////////////////////////////////////////////////////////////////
  624.  
  625. //////////////////////////////////////////////////////////////////////////////////
  626. if can_draw_intra
  627. intra_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  628. if displayStyle == 'Right Anchored'
  629. intra_time := get_limit_right(radistance)
  630. intra_time
  631.  
  632.  
  633. 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)
  634. 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)
  635.  
  636. line.set_x1(intra_line, intra_time)
  637. line.set_x2(intra_line, intra_limit_right)
  638. line.set_y1(intra_line, intra_open)
  639. line.set_y2(intra_line, intra_open)
  640. label.set_x(intra_label, intra_limit_right)
  641. label.set_y(intra_label, intra_open)
  642. label.set_text(intra_label, iotext)
  643. if mergebool
  644. f_LevelMerge(pricearray, labelarray, intra_open, intra_label, IntraColor)
  645.  
  646.  
  647. //////////////////////////////////////////////////////////////////////////////////
  648. //HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH
  649. if can_draw_intrah
  650. intrah_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  651. if displayStyle == 'Right Anchored'
  652. intrah_time := get_limit_right(radistance)
  653. intrah_time
  654.  
  655.  
  656.  
  657. 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)
  658. 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)
  659.  
  660. line.set_x1(intrah_line, intrah_time)
  661. line.set_x2(intrah_line, intrah_limit_right)
  662. line.set_y1(intrah_line, intrah_open)
  663. line.set_y2(intrah_line, intrah_open)
  664. label.set_x(intrah_label, intrah_limit_right)
  665. label.set_y(intrah_label, intrah_open)
  666. label.set_text(intrah_label, pihtext)
  667. if mergebool
  668. f_LevelMerge(pricearray, labelarray, intrah_open, intrah_label, IntraColor)
  669.  
  670. //////////////////////////////////////////////////////////////////////////////////
  671. //LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW
  672. if can_draw_intral
  673. intral_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  674. if displayStyle == 'Right Anchored'
  675. intral_time := get_limit_right(radistance)
  676. intral_time
  677.  
  678.  
  679.  
  680. 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)
  681. 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)
  682.  
  683. line.set_x1(intral_line, intral_time)
  684. line.set_x2(intral_line, intral_limit_right)
  685. line.set_y1(intral_line, intral_open)
  686. line.set_y2(intral_line, intral_open)
  687. label.set_x(intral_label, intral_limit_right)
  688. label.set_y(intral_label, intral_open)
  689. label.set_text(intral_label, piltext)
  690. if mergebool
  691. f_LevelMerge(pricearray, labelarray, intral_open, intral_label, IntraColor)
  692.  
  693. ///////////////////////////////////////////////////////////////////////////////
  694.  
  695. if can_draw_intram
  696. intram_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  697. intram_time = intrah_time
  698. intram_open = (intral_open + intrah_open) / 2
  699. if displayStyle == 'Right Anchored'
  700. intram_time := get_limit_right(radistance)
  701. intram_time
  702.  
  703. 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)
  704. 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)
  705. line.set_x1(intram_line, intram_time)
  706. line.set_x2(intram_line, intram_limit_right)
  707. line.set_y1(intram_line, intram_open)
  708. line.set_y2(intram_line, intram_open)
  709. label.set_x(intram_label, intram_limit_right)
  710. label.set_y(intram_label, intram_open)
  711. label.set_text(intram_label, pimtext)
  712. if mergebool
  713. f_LevelMerge(pricearray, labelarray, intram_open, intram_label, IntraColor)
  714.  
  715. ////////////////////////////////////////// MONDAY
  716.  
  717. if is_monday_enabled
  718. monday_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  719. if displayStyle == 'Right Anchored'
  720. monday_time := get_limit_right(radistance)
  721. monday_time
  722.  
  723. 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)
  724. 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)
  725.  
  726. line.set_x1(monday_line, monday_time)
  727. line.set_x2(monday_line, monday_limit_right)
  728. line.set_y1(monday_line, monday_high)
  729. line.set_y2(monday_line, monday_high)
  730. label.set_x(monday_label, monday_limit_right)
  731. label.set_y(monday_label, monday_high)
  732. label.set_text(monday_label, pmonhtext)
  733. if mergebool
  734. f_LevelMerge(pricearray, labelarray, monday_high, monday_label, MondayColor)
  735.  
  736.  
  737. if is_monday_enabled
  738. monday_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  739. if displayStyle == 'Right Anchored'
  740. monday_time := get_limit_right(radistance)
  741. monday_time
  742.  
  743.  
  744.  
  745. 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)
  746. 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)
  747.  
  748. line.set_x1(monday_low_line, monday_time)
  749. line.set_x2(monday_low_line, monday_limit_right)
  750. line.set_y1(monday_low_line, monday_low)
  751. line.set_y2(monday_low_line, monday_low)
  752. label.set_x(monday_low_label, monday_limit_right)
  753. label.set_y(monday_low_label, monday_low)
  754. label.set_text(monday_low_label, pmonltext)
  755. if mergebool
  756. f_LevelMerge(pricearray, labelarray, monday_low, monday_low_label, MondayColor)
  757.  
  758.  
  759.  
  760. if is_monday_mid
  761. mondaym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  762.  
  763. mondaym_open = (monday_high + monday_low) / 2
  764. if displayStyle == 'Right Anchored'
  765. monday_time := get_limit_right(radistance)
  766. monday_time
  767.  
  768. 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)
  769. 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)
  770. line.set_x1(mondaym_line, monday_time)
  771. line.set_x2(mondaym_line, mondaym_limit_right)
  772. line.set_y1(mondaym_line, mondaym_open)
  773. line.set_y2(mondaym_line, mondaym_open)
  774. label.set_x(mondaym_label, mondaym_limit_right)
  775. label.set_y(mondaym_label, mondaym_open)
  776. label.set_text(mondaym_label, pmonmtext)
  777. if mergebool
  778. f_LevelMerge(pricearray, labelarray, mondaym_open, mondaym_label, MondayColor)
  779.  
  780.  
  781. //////////////////////////////////////////////////////////////////////////////////
  782. ////////////////////////DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN
  783.  
  784. if is_daily_enabled
  785. daily_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  786. if displayStyle == 'Right Anchored'
  787. daily_time := get_limit_right(radistance)
  788. daily_time
  789.  
  790. 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)
  791. 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)
  792.  
  793. line.set_x1(daily_line, daily_time)
  794. line.set_x2(daily_line, daily_limit_right)
  795. line.set_y1(daily_line, daily_open)
  796. line.set_y2(daily_line, daily_open)
  797. label.set_x(daily_label, daily_limit_right)
  798. label.set_y(daily_label, daily_open)
  799. label.set_text(daily_label, dotext)
  800. if mergebool
  801. f_LevelMerge(pricearray, labelarray, daily_open, daily_label, DailyColor)
  802.  
  803. //////////////////////////////////////////////////////////////////////////////////
  804. //////////////////DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH
  805.  
  806. if is_dailyrange_enabled
  807. dailyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  808. if displayStyle == 'Right Anchored'
  809. dailyh_time := get_limit_right(radistance)
  810. dailyh_time
  811. // draw tails before lines for better visual
  812.  
  813.  
  814. 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)
  815. 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)
  816.  
  817. line.set_x1(dailyh_line, dailyh_time)
  818. line.set_x2(dailyh_line, dailyh_limit_right)
  819. line.set_y1(dailyh_line, dailyh_open)
  820. line.set_y2(dailyh_line, dailyh_open)
  821. label.set_x(dailyh_label, dailyh_limit_right)
  822. label.set_y(dailyh_label, dailyh_open)
  823. label.set_text(dailyh_label, pdhtext)
  824. if mergebool
  825. f_LevelMerge(pricearray, labelarray, dailyh_open, dailyh_label, DailyColor)
  826.  
  827.  
  828. //////////////////////////////////////////////////////////////////////////////////
  829. //////////////////DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW
  830.  
  831. if is_dailyrange_enabled
  832. dailyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  833. if displayStyle == 'Right Anchored'
  834. dailyl_time := get_limit_right(radistance)
  835. dailyl_time
  836.  
  837.  
  838. 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)
  839. 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)
  840.  
  841. line.set_x1(dailyl_line, dailyl_time)
  842. line.set_x2(dailyl_line, dailyl_limit_right)
  843. line.set_y1(dailyl_line, dailyl_open)
  844. line.set_y2(dailyl_line, dailyl_open)
  845. label.set_x(dailyl_label, dailyl_limit_right)
  846. label.set_y(dailyl_label, dailyl_open)
  847. label.set_text(dailyl_label, pdltext)
  848. if mergebool
  849. f_LevelMerge(pricearray, labelarray, dailyl_open, dailyl_label, DailyColor)
  850.  
  851.  
  852.  
  853. //////////////////////////////////////////////////////////////////////////////// Daily MID
  854.  
  855. if is_dailym_enabled
  856. dailym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  857. dailym_time = dailyh_time
  858. dailym_open = (dailyl_open + dailyh_open) / 2
  859. if displayStyle == 'Right Anchored'
  860. dailym_time := get_limit_right(radistance)
  861. dailym_time
  862. 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)
  863. 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)
  864. line.set_x1(dailym_line, dailym_time)
  865. line.set_x2(dailym_line, dailym_limit_right)
  866. line.set_y1(dailym_line, dailym_open)
  867. line.set_y2(dailym_line, dailym_open)
  868. label.set_x(dailym_label, dailym_limit_right)
  869. label.set_y(dailym_label, dailym_open)
  870. label.set_text(dailym_label, pdmtext)
  871. if mergebool
  872. f_LevelMerge(pricearray, labelarray, dailym_open, dailym_label, DailyColor)
  873.  
  874.  
  875. //////////////////////////////////////////////////////////////////////////////////
  876.  
  877.  
  878. if is_weekly_enabled
  879. weekly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  880. cweekly_time = weekly_time
  881. if displayStyle == 'Right Anchored'
  882. cweekly_time := get_limit_right(radistance)
  883. cweekly_time
  884.  
  885.  
  886. 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)
  887. 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)
  888.  
  889. line.set_x1(weekly_line, cweekly_time)
  890. line.set_x2(weekly_line, weekly_limit_right)
  891. line.set_y1(weekly_line, weekly_open)
  892. line.set_y2(weekly_line, weekly_open)
  893. label.set_x(weekly_label, weekly_limit_right)
  894. label.set_y(weekly_label, weekly_open)
  895. label.set_text(weekly_label, wotext)
  896. if mergebool
  897. f_LevelMerge(pricearray, labelarray, weekly_open, weekly_label, WeeklyColor)
  898. // the weekly open can be the daily open too (monday)
  899. // only the weekly will be draw, in these case we update its label
  900. // if is_weekly_open and can_show_daily
  901. // label.set_text(weekly_label, "DO / WO ")
  902.  
  903. //////////////////////////////////////////////////////////////////////////////////
  904. ////////////////////////////////////////////////////////////////////////////////// WEEKLY HIGH WEEKLY HIGH WEEKLY HIGH
  905.  
  906.  
  907. if is_weeklyrange_enabled
  908. weeklyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  909. if displayStyle == 'Right Anchored'
  910. weeklyh_time := get_limit_right(radistance)
  911. weeklyh_time
  912.  
  913.  
  914. 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)
  915. 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)
  916.  
  917. line.set_x1(weeklyh_line, weeklyh_time)
  918. line.set_x2(weeklyh_line, weeklyh_limit_right)
  919. line.set_y1(weeklyh_line, weeklyh_open)
  920. line.set_y2(weeklyh_line, weeklyh_open)
  921. label.set_x(weeklyh_label, weeklyh_limit_right)
  922. label.set_y(weeklyh_label, weeklyh_open)
  923. label.set_text(weeklyh_label, pwhtext)
  924. if mergebool
  925. f_LevelMerge(pricearray, labelarray, weeklyh_open, weeklyh_label, WeeklyColor)
  926.  
  927. //////////////////////////////////////////////////////////////////////////////////
  928. ////////////////////////////////////////////////////////////////////////////////// WEEKLY LOW WEEKLY LOW WEEKLY LOW
  929.  
  930.  
  931. if is_weeklyrange_enabled
  932. weeklyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  933. if displayStyle == 'Right Anchored'
  934. weeklyl_time := get_limit_right(radistance)
  935. weeklyl_time
  936.  
  937.  
  938. 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)
  939. 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)
  940.  
  941. line.set_x1(weeklyl_line, weeklyl_time)
  942. line.set_x2(weeklyl_line, weeklyl_limit_right)
  943. line.set_y1(weeklyl_line, weeklyl_open)
  944. line.set_y2(weeklyl_line, weeklyl_open)
  945. label.set_x(weeklyl_label, weeklyl_limit_right)
  946. label.set_y(weeklyl_label, weeklyl_open)
  947. label.set_text(weeklyl_label, pwltext)
  948. if mergebool
  949. f_LevelMerge(pricearray, labelarray, weeklyl_open, weeklyl_label, WeeklyColor)
  950.  
  951.  
  952.  
  953. //////////////////////////////////////////////////////////////////////////////////
  954. //////////////////////////////////////////////////////////////////////////////// Weekly MID
  955.  
  956. if is_weekly_mid
  957. weeklym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  958. weeklym_time = weeklyh_time
  959. weeklym_open = (weeklyl_open + weeklyh_open) / 2
  960. if displayStyle == 'Right Anchored'
  961. weeklym_time := get_limit_right(radistance)
  962. weeklym_time
  963.  
  964. 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)
  965. 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)
  966. line.set_x1(weeklym_line, weeklym_time)
  967. line.set_x2(weeklym_line, weeklym_limit_right)
  968. line.set_y1(weeklym_line, weeklym_open)
  969. line.set_y2(weeklym_line, weeklym_open)
  970. label.set_x(weeklym_label, weeklym_limit_right)
  971. label.set_y(weeklym_label, weeklym_open)
  972. label.set_text(weeklym_label, pwmtext)
  973. if mergebool
  974. f_LevelMerge(pricearray, labelarray, weeklym_open, weeklym_label, WeeklyColor)
  975. ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY LOW LOW LOW
  976.  
  977.  
  978. if is_yearlyrange_enabled
  979. yearlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  980. if displayStyle == 'Right Anchored'
  981. yearlyl_time := get_limit_right(radistance)
  982. yearlyl_time
  983.  
  984.  
  985. 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)
  986. 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)
  987.  
  988. line.set_x1(yearlyl_line, yearlyl_time)
  989. line.set_x2(yearlyl_line, yearlyl_limit_right)
  990. line.set_y1(yearlyl_line, yearlyl_open)
  991. line.set_y2(yearlyl_line, yearlyl_open)
  992. label.set_x(yearlyl_label, yearlyl_limit_right)
  993. label.set_y(yearlyl_label, yearlyl_open)
  994. label.set_text(yearlyl_label, cyltext)
  995. if mergebool
  996. f_LevelMerge(pricearray, labelarray, yearlyl_open, yearlyl_label, YearlyColor)
  997.  
  998.  
  999.  
  1000. //////////////////////////////////////////////////////////////////////////////////
  1001.  
  1002.  
  1003. ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY HIGH HIGH HIGH
  1004.  
  1005.  
  1006. if is_yearlyrange_enabled
  1007. yearlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1008. if displayStyle == 'Right Anchored'
  1009. yearlyh_time := get_limit_right(radistance)
  1010. yearlyh_time
  1011.  
  1012.  
  1013. 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)
  1014. 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)
  1015.  
  1016. line.set_x1(yearlyh_line, yearlyh_time)
  1017. line.set_x2(yearlyh_line, yearlyh_limit_right)
  1018. line.set_y1(yearlyh_line, yearlyh_open)
  1019. line.set_y2(yearlyh_line, yearlyh_open)
  1020. label.set_x(yearlyh_label, yearlyh_limit_right)
  1021. label.set_y(yearlyh_label, yearlyh_open)
  1022. label.set_text(yearlyh_label, cyhtext)
  1023. if mergebool
  1024. f_LevelMerge(pricearray, labelarray, yearlyh_open, yearlyh_label, YearlyColor)
  1025.  
  1026.  
  1027.  
  1028. //////////////////////////////////////////////////////////////////////////////////
  1029.  
  1030. ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY OPEN
  1031.  
  1032.  
  1033. if is_yearly_enabled
  1034. yearly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1035. if displayStyle == 'Right Anchored'
  1036. yearly_time := get_limit_right(radistance)
  1037. yearly_time
  1038.  
  1039.  
  1040. 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)
  1041.  
  1042. 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)
  1043.  
  1044.  
  1045.  
  1046. line.set_x1(yearly_line, yearly_time)
  1047. line.set_x2(yearly_line, yearly_limit_right)
  1048. line.set_y1(yearly_line, yearly_open)
  1049. line.set_y2(yearly_line, yearly_open)
  1050. label.set_x(yearly_label, yearly_limit_right)
  1051. label.set_y(yearly_label, yearly_open)
  1052. label.set_text(yearly_label, yotext)
  1053. if mergebool
  1054. f_LevelMerge(pricearray, labelarray, yearly_open, yearly_label, YearlyColor)
  1055.  
  1056.  
  1057.  
  1058. //////////////////////////////////////////////////////////////////////////////////
  1059. //////////////////////////////////////////////////////////////////////////////// yearly MID
  1060.  
  1061. if is_yearly_mid
  1062. yearlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1063. yearlym_time = yearlyh_time
  1064. yearlym_open = (yearlyl_open + yearlyh_open) / 2
  1065. if displayStyle == 'Right Anchored'
  1066. yearlym_time := get_limit_right(radistance)
  1067. yearlym_time
  1068.  
  1069. 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)
  1070. 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)
  1071. line.set_x1(yearlym_line, yearlym_time)
  1072. line.set_x2(yearlym_line, yearlym_limit_right)
  1073. line.set_y1(yearlym_line, yearlym_open)
  1074. line.set_y2(yearlym_line, yearlym_open)
  1075. label.set_x(yearlym_label, yearlym_limit_right)
  1076. label.set_y(yearlym_label, yearlym_open)
  1077. label.set_text(yearlym_label, cymtext)
  1078. if mergebool
  1079. f_LevelMerge(pricearray, labelarray, yearlym_open, yearlym_label, YearlyColor)
  1080.  
  1081.  
  1082. ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY OPEN
  1083.  
  1084.  
  1085. if is_quarterly_enabled
  1086. quarterly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1087. if displayStyle == 'Right Anchored'
  1088. quarterly_time := get_limit_right(radistance)
  1089. quarterly_time
  1090.  
  1091.  
  1092. 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)
  1093. 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)
  1094.  
  1095. line.set_x1(quarterly_line, quarterly_time)
  1096. line.set_x2(quarterly_line, quarterly_limit_right)
  1097. line.set_y1(quarterly_line, quarterly_open)
  1098. line.set_y2(quarterly_line, quarterly_open)
  1099. label.set_x(quarterly_label, quarterly_limit_right)
  1100. label.set_y(quarterly_label, quarterly_open)
  1101. label.set_text(quarterly_label, qotext)
  1102. if mergebool
  1103. f_LevelMerge(pricearray, labelarray, quarterly_open, quarterly_label, quarterlyColor)
  1104.  
  1105.  
  1106.  
  1107. //////////////////////////////////////////////////////////////////////////////////
  1108.  
  1109.  
  1110. ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY High
  1111.  
  1112.  
  1113. if is_quarterlyrange_enabled
  1114. quarterlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1115. if displayStyle == 'Right Anchored'
  1116. quarterlyh_time := get_limit_right(radistance)
  1117. quarterlyh_time
  1118.  
  1119.  
  1120. 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)
  1121. 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)
  1122.  
  1123. line.set_x1(quarterlyh_line, quarterlyh_time)
  1124. line.set_x2(quarterlyh_line, quarterlyh_limit_right)
  1125. line.set_y1(quarterlyh_line, quarterlyh_open)
  1126. line.set_y2(quarterlyh_line, quarterlyh_open)
  1127. label.set_x(quarterlyh_label, quarterlyh_limit_right)
  1128. label.set_y(quarterlyh_label, quarterlyh_open)
  1129. label.set_text(quarterlyh_label, pqhtext)
  1130. if mergebool
  1131. f_LevelMerge(pricearray, labelarray, quarterlyh_open, quarterlyh_label, quarterlyColor)
  1132.  
  1133.  
  1134.  
  1135. //////////////////////////////////////////////////////////////////////////////////
  1136.  
  1137.  
  1138. ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY Low
  1139.  
  1140.  
  1141. if is_quarterlyrange_enabled
  1142. quarterlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1143. if displayStyle == 'Right Anchored'
  1144. quarterlyl_time := get_limit_right(radistance)
  1145. quarterlyl_time
  1146.  
  1147.  
  1148. 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)
  1149. 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)
  1150.  
  1151. line.set_x1(quarterlyl_line, quarterlyl_time)
  1152. line.set_x2(quarterlyl_line, quarterlyl_limit_right)
  1153. line.set_y1(quarterlyl_line, quarterlyl_open)
  1154. line.set_y2(quarterlyl_line, quarterlyl_open)
  1155. label.set_x(quarterlyl_label, quarterlyl_limit_right)
  1156. label.set_y(quarterlyl_label, quarterlyl_open)
  1157.  
  1158. label.set_text(quarterlyl_label, pqltext)
  1159. if mergebool
  1160. f_LevelMerge(pricearray, labelarray, quarterlyl_open, quarterlyl_label, quarterlyColor)
  1161.  
  1162.  
  1163.  
  1164. //////////////////////////////////////////////////////////////////////////////////
  1165. //////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY MID
  1166.  
  1167. if is_quarterly_mid
  1168. quarterlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1169. quarterlym_time = quarterlyh_time
  1170. quarterlym_open = (quarterlyl_open + quarterlyh_open) / 2
  1171. if displayStyle == 'Right Anchored'
  1172. quarterlym_time := get_limit_right(radistance)
  1173. quarterlym_time
  1174. 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)
  1175. 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)
  1176. line.set_x1(quarterlym_line, quarterlym_time)
  1177. line.set_x2(quarterlym_line, quarterlym_limit_right)
  1178. line.set_y1(quarterlym_line, quarterlym_open)
  1179. line.set_y2(quarterlym_line, quarterlym_open)
  1180. label.set_x(quarterlym_label, quarterlym_limit_right)
  1181. label.set_y(quarterlym_label, quarterlym_open)
  1182.  
  1183. label.set_text(quarterlym_label, pqmtext)
  1184. if mergebool
  1185. f_LevelMerge(pricearray, labelarray, quarterlym_open, quarterlym_label, quarterlyColor)
  1186.  
  1187. ////////////////////////////////////////////////////////////////////////////////// Monthly LOW LOW LOW
  1188.  
  1189.  
  1190. if is_monthlyrange_enabled
  1191. monthlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1192. if displayStyle == 'Right Anchored'
  1193. monthlyl_time := get_limit_right(radistance)
  1194. monthlyl_time
  1195.  
  1196.  
  1197. 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)
  1198. 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)
  1199.  
  1200. line.set_x1(monthlyl_line, monthlyl_time)
  1201. line.set_x2(monthlyl_line, monthlyl_limit_right)
  1202. line.set_y1(monthlyl_line, monthlyl_open)
  1203. line.set_y2(monthlyl_line, monthlyl_open)
  1204. label.set_x(monthlyl_label, monthlyl_limit_right)
  1205. label.set_y(monthlyl_label, monthlyl_open)
  1206. label.set_text(monthlyl_label, pmltext)
  1207. if mergebool
  1208. f_LevelMerge(pricearray, labelarray, monthlyl_open, monthlyl_label, MonthlyColor)
  1209. // the weekly open can be the daily open too (monday)
  1210. // only the weekly will be draw, in these case we update its label
  1211.  
  1212.  
  1213. //////////////////////////////////////////////////////////////////////////////////
  1214. ////////////////////////////////////////////////////////////////////////////////// MONTHLY HIGH HIGH HIGH
  1215.  
  1216.  
  1217.  
  1218. if is_monthlyrange_enabled
  1219. monthlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1220. if displayStyle == 'Right Anchored'
  1221. monthlyh_time := get_limit_right(radistance)
  1222. monthlyh_time
  1223.  
  1224.  
  1225. 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)
  1226. 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)
  1227.  
  1228. line.set_x1(monthlyh_line, monthlyl_time)
  1229. line.set_x2(monthlyh_line, monthlyh_limit_right)
  1230. line.set_y1(monthlyh_line, monthlyh_open)
  1231. line.set_y2(monthlyh_line, monthlyh_open)
  1232. label.set_x(monthlyh_label, monthlyh_limit_right)
  1233. label.set_y(monthlyh_label, monthlyh_open)
  1234. label.set_text(monthlyh_label, pmhtext)
  1235. if mergebool
  1236. f_LevelMerge(pricearray, labelarray, monthlyh_open, monthlyh_label, MonthlyColor)
  1237. // the weekly open can be the daily open too (monday)
  1238. // only the weekly will be draw, in these case we update its label
  1239.  
  1240. //////////////////////////////////////////////////////////////////////////////// MONTHLY MID
  1241.  
  1242. if is_monthly_mid
  1243. monthlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1244. monthlym_time = monthlyh_time
  1245. monthlym_open = (monthlyl_open + monthlyh_open) / 2
  1246. if displayStyle == 'Right Anchored'
  1247. monthlym_time := get_limit_right(radistance)
  1248. monthlym_time
  1249. 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)
  1250. 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)
  1251. line.set_x1(monthlym_line, monthlym_time)
  1252. line.set_x2(monthlym_line, monthlym_limit_right)
  1253. line.set_y1(monthlym_line, monthlym_open)
  1254. line.set_y2(monthlym_line, monthlym_open)
  1255. label.set_x(monthlym_label, monthlym_limit_right)
  1256. label.set_y(monthlym_label, monthlym_open)
  1257. label.set_text(monthlym_label, pmmtext)
  1258. if mergebool
  1259. f_LevelMerge(pricearray, labelarray, monthlym_open, monthlym_label, MonthlyColor)
  1260. //////////////////////////////////////////////////////////////////////////////////
  1261.  
  1262.  
  1263.  
  1264. if is_monthly_enabled
  1265. monthly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1266. if displayStyle == 'Right Anchored'
  1267. monthly_time := get_limit_right(radistance)
  1268. monthly_time
  1269.  
  1270. 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)
  1271. 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)
  1272.  
  1273. line.set_x1(monthlyLine, monthly_time)
  1274. line.set_x2(monthlyLine, monthly_limit_right)
  1275. line.set_y1(monthlyLine, monthly_open)
  1276. line.set_y2(monthlyLine, monthly_open)
  1277. label.set_x(monthlyLabel, monthly_limit_right)
  1278. label.set_y(monthlyLabel, monthly_open)
  1279. label.set_text(monthlyLabel, motext)
  1280. if mergebool
  1281. f_LevelMerge(pricearray, labelarray, monthly_open, monthlyLabel, MonthlyColor)
  1282.  
  1283.  
  1284. /////////////////////////////////////////////////////////////////////////////
  1285.  
  1286. // the monthly open can be the weekly open (monday 1st) and/or daily open too
  1287. // only the monthly will be draw, in these case we update its label
  1288. // if is_monthly_open
  1289. // if can_show_daily
  1290. // label.set_text(monthlyLabel, "DO / MO ")
  1291. // if is_weekly_open
  1292. // if can_show_weekly
  1293. // label.set_text(monthlyLabel, "WO / MO ")
  1294. // if can_show_daily and can_show_weekly
  1295. // label.set_text(monthlyLabel, "DO / WO / MO ")
  1296.  
  1297. // the start of the line is drew from the first week of the month
  1298. // if the first day of the weekly candle (monday) is the 2nd of the month
  1299. // we fix the start of the line position on the Prev weekly candle
  1300. if timeframe.isweekly and dayofweek(monthly_time) != dayofweek.monday
  1301. line.set_x1(monthlyLine, monthly_time - (weekly_time - weekly_time[1]))
  1302.  
  1303.  
  1304.  
Advertisement
Add Comment
Please, Sign In to add comment