Advertisement
xmd79

DJ Key Levels

Jan 10th, 2023
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 66.17 KB | None | 0 0
  1. //@version=5
  2. //@mrSebastienC thank you for doing the base code
  3. //@spacemanBTC thank you for improving the base code
  4. //The timing of the sessions follows according to NewYork Timezone and taken from www.forex.timezoneconverter.com
  5.  
  6. indicator('DJ Key Levels', shorttitle='DJ Key Levels', overlay=true, max_lines_count=100)
  7.  
  8. GlobalTextType = true
  9. var globalcoloring = false
  10. GlobalColor = color.white
  11. //var show_tails = input(defval = false, title = "Always Show", type = input.bool)
  12.  
  13.  
  14. [daily_time, daily_open] = request.security(syminfo.tickerid, 'D', [time, open], lookahead=barmerge.lookahead_on)
  15. [dailyh_time, dailyh_open] = request.security(syminfo.tickerid, 'D', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  16. [dailyl_time, dailyl_open] = request.security(syminfo.tickerid, 'D', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  17.  
  18. cdailyh_open = request.security(syminfo.tickerid, 'D', high, lookahead=barmerge.lookahead_on)
  19. cdailyl_open = request.security(syminfo.tickerid, 'D', low, lookahead=barmerge.lookahead_on)
  20. var monday_time = time
  21. var monday_high = high
  22. var monday_low = low
  23.  
  24. [weekly_time, weekly_open] = request.security(syminfo.tickerid, 'W', [time, open], lookahead=barmerge.lookahead_on)
  25. [weeklyh_time, weeklyh_open] = request.security(syminfo.tickerid, 'W', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  26. [weeklyl_time, weeklyl_open] = request.security(syminfo.tickerid, 'W', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  27.  
  28.  
  29. [monthly_time, monthly_open] = request.security(syminfo.tickerid, 'M', [time, open], lookahead=barmerge.lookahead_on)
  30. [monthlyh_time, monthlyh_open] = request.security(syminfo.tickerid, 'M', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  31. [monthlyl_time, monthlyl_open] = request.security(syminfo.tickerid, 'M', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  32.  
  33.  
  34. [quarterly_time, quarterly_open] = request.security(syminfo.tickerid, '3M', [time, open], lookahead=barmerge.lookahead_on)
  35. [quarterlyh_time, quarterlyh_open] = request.security(syminfo.tickerid, '3M', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  36. [quarterlyl_time, quarterlyl_open] = request.security(syminfo.tickerid, '3M', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  37.  
  38.  
  39. [yearly_time, yearly_open] = request.security(syminfo.tickerid, '12M', [time, open], lookahead=barmerge.lookahead_on)
  40. [yearlyh_time, yearlyh_open] = request.security(syminfo.tickerid, '12M', [time, high], lookahead=barmerge.lookahead_on)
  41. [yearlyl_time, yearlyl_open] = request.security(syminfo.tickerid, '12M', [time, low], lookahead=barmerge.lookahead_on)
  42.  
  43.  
  44. [intra_time, intra_open] = request.security(syminfo.tickerid, '240', [time, open], lookahead=barmerge.lookahead_on)
  45. [intrah_time, intrah_open] = request.security(syminfo.tickerid, '240', [time[1], high[1]], lookahead=barmerge.lookahead_on)
  46. [intral_time, intral_open] = request.security(syminfo.tickerid, '240', [time[1], low[1]], lookahead=barmerge.lookahead_on)
  47.  
  48. //------------------------------ Inputs -------------------------------
  49.  
  50.  
  51.  
  52. var is_intra_enabled = input.bool(defval=false, title='Open', group='4H', inline='4H')
  53. var is_intrarange_enabled = input.bool(defval=false, title='Prev H/L', group='4H', inline='4H')
  54. var is_intram_enabled = input.bool(defval=false, title='Prev Mid', group='4H', inline='4H')
  55. IntraTextType = false
  56.  
  57. var is_daily_enabled = input.bool(defval=false, title='Open', group='Daily', inline='Daily')
  58. var is_dailyrange_enabled = input.bool(defval=true, title='Prev H/L', group='Daily', inline='Daily')
  59. var is_dailym_enabled = input.bool(defval=false, title='Prev Mid', group='Daily', inline='Daily')
  60. DailyTextType = false
  61.  
  62. var is_monday_enabled = input.bool(defval=true, title='Range', group='Monday Range', inline='Monday')
  63. var is_monday_mid = input.bool(defval=true, title='Mid', group='Monday Range', inline='Monday')
  64. var untested_monday = false
  65. MondayTextType = false
  66.  
  67. var is_weekly_enabled = input.bool(defval=false, title='Open', group='Weekly', inline='Weekly')
  68. var is_weeklyrange_enabled = input.bool(defval=true, title='Prev H/L', group='Weekly', inline='Weekly')
  69. var is_weekly_mid = input.bool(defval=false, title='Prev Mid', group='Weekly', inline='Weekly')
  70. WeeklyTextType = false
  71.  
  72. var is_monthly_enabled = input.bool(defval=false, title='Open', group='Monthly', inline='Monthly')
  73. var is_monthlyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Monthly', inline='Monthly')
  74. var is_monthly_mid = input.bool(defval=false, title='Prev Mid', group='Monthly', inline='Monthly')
  75. MonthlyTextType = false
  76.  
  77. var is_quarterly_enabled = input.bool(defval=true, title='Open', group='Quarterly', inline='Quarterly')
  78. var is_quarterlyrange_enabled = input.bool(defval=false, title='Prev H/L', group='Quarterly', inline='Quarterly')
  79. var is_quarterly_mid = input.bool(defval=false, title='Prev Mid', group='Quarterly', inline='Quarterly')
  80. QuarterlyTextType = false
  81.  
  82. var is_yearly_enabled = input.bool(defval=true, title='Open', group='Yearly', inline='Yearly')
  83. var is_yearlyrange_enabled = input.bool(defval=false, title='Current H/L', group='Yearly', inline='Yearly')
  84. var is_yearly_mid = input.bool(defval=false, title='Mid', group='Yearly', inline='Yearly')
  85. YearlyTextType = false
  86.  
  87. SessionTextType = false
  88.  
  89. displayStyle = input.string(defval='Standard', title='Display Style', options=['Standard', 'Right Anchored'], inline='Display')
  90. mergebool = input.bool(defval=true, title='Merge Levels?', inline='Display')
  91. distanceright = input.int(defval=30, title='Distance', minval=5, maxval=500, inline='Dist')
  92. radistance = input.int(defval=250, title='Anchor Distance', minval=5, maxval=500, inline='Dist')
  93. labelsize = input.string(defval='Medium', title='Text Size', options=['Small', 'Medium', 'Large'])
  94. linesize = input.string(defval='Small', title='Line Width', options=['Small', 'Medium', 'Large'], inline='Line')
  95. linestyle = input.string(defval='Solid', title='Line Style', options=['Solid', 'Dashed', 'Dotted'], inline='Line')
  96.  
  97.  
  98. // London
  99.  
  100. var is_londonrange_enabled = input.bool(defval=false, title='London Range', inline="london", group='London Session')
  101. LondonColor = input.color(title='', defval=color.white, group='London Session', inline='london')
  102.  
  103. show_london_range = input.bool(false, title='London Session',inline="london",group="London Session")
  104. londonbox_col = input.color(color.new(color.olive,90), '', inline="london",group="London Session")
  105. londonboxborder_col = color.black
  106. londonbrtype = "No border"
  107.  
  108. london = input.session('0300-1101',"London Time",group="London Session")
  109. Londont = london
  110.  
  111. //New York
  112.  
  113. var is_usrange_enabled = input.bool(defval=false, title='New York Range', group='New York Session', inline='ny')
  114. USColor = input.color(title='', defval=color.white, group='New York Session', inline='ny')
  115.  
  116. show_newyork_range = input.bool(false, title='New York Session', group='New York Session', inline='ny')
  117. newyorkbox_col = input.color(color.new(color.blue,90), '', group='New York Session', inline='ny')
  118. newyorkboxborder_col = color.black
  119. nybrtype = "No border"
  120.  
  121. newyork = input.session('0800-1601',"New York",group="New York Session")
  122. USt = newyork
  123.  
  124. //Asia
  125.  
  126. var is_asiarange_enabled = input.bool(defval=false, title='Asia Range', group='Asia Session', inline='asia')
  127. AsiaColor = input.color(title='', defval=color.white, group='Asia Session', inline='asia')
  128.  
  129.  
  130. show_asian_range = input.bool(false, title='Asia Session', group='Asia Session', inline='asia')
  131. _asianSess = "Asian Range"
  132.  
  133. asiabox_col = input.color(color.new(color.orange, 90), '', group='Asia Session', inline='asia')
  134. asiaboxborder_col = color.black
  135. asiabrtype = "No border"
  136.  
  137. asia = input.session('1800-0301',"Asia",group="Asia Session")
  138. Asiat = asia
  139.  
  140.  
  141. //General
  142. fil = input.bool(true,"Fill Box ",group="Session Settings", inline='general1')
  143. br = input.bool(true,"Show Borders ",group="Session Settings", inline = 'general1')
  144.  
  145. show_lbl = input.bool(true,"Show Labels", group="Session Settings", inline='general2')
  146. show_day = input.bool(true,"Show Day",group="Session Settings", inline='general2')
  147.  
  148. size = input.string("Normal","Label Size",options=["Tiny","Small","Normal","Huge"],group="Session Settings", inline='general3')
  149. type = input.string("Range Box","Session Style",options = ["Range Box","BG Highlightlight"],group="Session Settings", inline='general3')
  150.  
  151.  
  152. //------------------Genral Functions------------------------//
  153.  
  154. in_session(sess) =>
  155. not na(time(timeframe.period, sess))
  156.  
  157. start_time(sess) =>
  158. int startTime = na
  159. startTime := in_session(sess) and not in_session(sess)[1] ? time : startTime[1]
  160. startTime
  161.  
  162. is_new_session(sess) =>
  163. t = time("D", sess)
  164. na(t[1]) and not na(t) or t[1] < t
  165.  
  166.  
  167. br_styl(string style)=>
  168. switch style
  169. "No border" => line.style_solid
  170. "Solid" => line.style_solid
  171. "Dashed" => line.style_dashed
  172. "Dotted" => line.style_dotted
  173. =>line.style_dotted
  174.  
  175.  
  176. lbl_size(string size)=>
  177. switch size
  178. "Tiny" => size.tiny
  179. "Small" => size.small
  180. "Normal" => size.normal
  181. "Huge" => size.huge
  182. =>size.small
  183.  
  184. nofil(ses) =>
  185. int ret = 0
  186.  
  187. if(ses == "No border" or br == false)
  188. ret:=100
  189. ret
  190. else
  191. ret
  192.  
  193.  
  194. sessToShow(sess) =>
  195. int ret = 0
  196.  
  197. if(sess == "Sydney")
  198. ret:=1
  199. ret
  200. else if (sess == "Tokyo")
  201. ret:=2
  202. ret
  203. else if (sess == "Both")
  204. ret:=3
  205. ret
  206. else
  207. ret
  208.  
  209.  
  210. timeinrange(res, sess) => time(res, sess) != 0
  211.  
  212. _dow() =>
  213. string day = " Monday"
  214.  
  215. if (dayofweek(time('D')) == dayofweek.monday and close )
  216. day := " Tuesday"
  217. day
  218. else if(dayofweek(time('D')) == dayofweek.tuesday and close )
  219. day := " Wednesday"
  220. day
  221. else if(dayofweek(time('D')) == dayofweek.wednesday and close)
  222. day := " Thursday"
  223. day
  224. else if(dayofweek(time('D')) == dayofweek.thursday and close )
  225. day := " Friday"
  226. day
  227. else if(dayofweek(time('D')) == dayofweek.friday and close )
  228. day := " Saturday"
  229. day
  230. else if(dayofweek(time('D')) == dayofweek.saturday and close )
  231. day :=" Sunday"
  232. day
  233. else if(dayofweek(time('D')) == dayofweek.sunday and close )
  234. day
  235.  
  236. //------------------Variables------------------------//
  237.  
  238. current_tf = str.tonumber(timeframe.period)
  239. bool valid_tf = current_tf <= 60
  240. bool boxType = (type == "Range Box")
  241.  
  242. _lblSize = lbl_size(size)
  243. _showLabel = ((show_lbl) and (fil or br)) ? 0:100
  244. _sessToShow = sessToShow(_asianSess)
  245. day = _dow()
  246. //--------------------Asia Session---------------------//
  247.  
  248.  
  249. asia_session = is_new_session(asia)
  250.  
  251.  
  252. box _asiabox = box(na)
  253. float _asialow = na
  254. float _asiahigh = na
  255. label _asialbl=label(na)
  256.  
  257. _asiastart = start_time(asia)
  258.  
  259. _asialow := asia_session ? low : in_session(asia) ? math.min(low, _asialow[1]) : na
  260. _asiahigh := asia_session ? high : in_session(asia) ? math.max(high, _asiahigh[1]) : na
  261.  
  262. _asiabrtype = br_styl(asiabrtype)
  263.  
  264. _inasia = in_session(asia) and valid_tf
  265.  
  266. bool _show_asianRange = ((_sessToShow == 0) and show_asian_range )
  267. int asbr = nofil(asiabrtype)
  268.  
  269. color _asiabox_col = fil?asiabox_col:color.new(color.black,100)
  270. string _astxt = (_show_asianRange and show_lbl )? ((show_day)?"AS "+day:"AS") :""
  271.  
  272.  
  273. if _inasia and boxType
  274. if in_session(asia)[1]
  275. label.delete(_asialbl[1])
  276. box.delete(_asiabox[1])
  277.  
  278. if low < _asialow
  279. _asialow := low
  280.  
  281. if high > _asiahigh
  282. _asiahigh := high
  283.  
  284. if _show_asianRange
  285. _asiabox := box.new(_asiastart, _asiahigh, time, _asialow, xloc=xloc.bar_time, bgcolor=_asiabox_col, border_color=color.new(asiaboxborder_col,asbr), border_style=_asiabrtype)
  286. _asialbl:= label.new( x= _asiastart,y=_asiahigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(asiaboxborder_col,_showLabel),text= _astxt)
  287. _asiabox
  288.  
  289. bgcolor(_show_asianRange and not(boxType) and timeinrange(timeframe.period, asia) ?_asiabox_col : na)
  290.  
  291.  
  292.  
  293. //--------------------London Session---------------------//
  294.  
  295.  
  296. london_session = is_new_session(london)
  297.  
  298. box _londonbox = box(na)
  299. float _londonlow = na
  300. float _londonhigh = na
  301. label _londonlbl=label(na)
  302.  
  303. _londonstart = start_time(london)
  304.  
  305. _londonlow := london_session ? low : in_session(london) ? math.min(low, _londonlow[1]) : na
  306. _londonhigh := london_session ? high : in_session(london) ? math.max(high, _londonhigh[1]) : na
  307.  
  308.  
  309. _inlondon = in_session(london) and valid_tf
  310.  
  311. _londonbrtype = br_styl(londonbrtype)
  312. color _londonbox_col = fil?londonbox_col:color.new(color.black,100)
  313. string _lntxt = (show_london_range and show_lbl and not(show_asian_range) )? ((show_day)?"LN "+day:"LN") :"LN"
  314.  
  315.  
  316. int lobr = nofil(londonbrtype)
  317.  
  318. if _inlondon and boxType
  319. if in_session(london)[1]
  320. label.delete(_londonlbl[1])
  321. box.delete(_londonbox[1])
  322.  
  323. if low < _londonlow
  324. _londonlow := low
  325.  
  326. if high > _londonhigh
  327. _londonhigh := high
  328.  
  329. if show_london_range
  330. _londonbox := box.new(_londonstart, _londonhigh, time, _londonlow, xloc=xloc.bar_time, bgcolor=_londonbox_col, border_color=color.new(londonboxborder_col,lobr), border_style=_londonbrtype)
  331. _londonlbl:= label.new( x= _londonstart,y=_londonhigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(londonboxborder_col,_showLabel),text= _lntxt)
  332. _londonbox
  333.  
  334. bgcolor(show_london_range and not(boxType) and timeinrange(timeframe.period,london) ?_londonbox_col : na)
  335.  
  336. //--------------------New York Session---------------------//
  337.  
  338.  
  339. newyork_session = is_new_session(newyork)
  340.  
  341. box _newyorkbox = box(na)
  342. float _newyorklow = na
  343. float _newyorkhigh = na
  344. label _nylbl=label(na)
  345.  
  346. _newyorkstart = start_time(newyork)
  347.  
  348. _newyorklow := newyork_session ? low : in_session(newyork) ? math.min(low, _newyorklow[1]) : na
  349. _newyorkhigh := newyork_session ? high : in_session(newyork) ? math.max(high, _newyorkhigh[1]) : na
  350.  
  351.  
  352. _innewyork = in_session(newyork) and valid_tf
  353.  
  354. _newyorkbrtype = br_styl(nybrtype)
  355. color _newyorkbox_col = fil?newyorkbox_col:color.new(color.black,100)
  356. string _nytxt = (show_newyork_range and show_lbl and not(show_asian_range) and not(show_london_range))? ((show_day)?"NY "+day:"NY") :"NY"
  357.  
  358. int nybr = nofil(nybrtype)
  359.  
  360. if _innewyork and boxType
  361. if in_session(newyork)[1]
  362. label.delete(_nylbl[1])
  363. box.delete(_newyorkbox[1])
  364.  
  365. if low < _newyorklow
  366. _newyorklow := low
  367.  
  368. if high > _newyorkhigh
  369. _newyorkhigh := high
  370.  
  371. if show_newyork_range
  372. _newyorkbox := box.new(_newyorkstart, _newyorkhigh, time, _newyorklow, xloc=xloc.bar_time, bgcolor=_newyorkbox_col, border_color=color.new(newyorkboxborder_col,nybr), border_style=_newyorkbrtype)
  373. _nylbl:= label.new( x= _newyorkstart,y=_newyorkhigh,style=label.style_label_lower_left,xloc=xloc.bar_time,size=_lblSize,color=color.new(color.black,100),textcolor=color.new(newyorkboxborder_col,_showLabel),text= _nytxt)
  374. _newyorkbox
  375.  
  376.  
  377. bgcolor(show_newyork_range and not(boxType) and timeinrange(timeframe.period, newyork) ?_newyorkbox_col : na)
  378.  
  379.  
  380. //
  381.  
  382. DailyColor = input.color(title='', defval=color.white, group='Daily', inline='Daily')
  383. MondayColor = input.color(title='', defval=color.blue, group='Monday Range', inline='Monday')
  384. WeeklyColor = input.color(title='', defval=color.red, group='Weekly', inline='Weekly')
  385. MonthlyColor = input.color(title='', defval=color.maroon, group='Monthly', inline='Monthly')
  386. YearlyColor = input.color(title='', defval=color.orange, group='Yearly', inline='Yearly')
  387. quarterlyColor = input.color(title='', defval=color.purple, group='Quarterly', inline='Quarterly')
  388. IntraColor = input.color(title='', defval=color.orange, group='4H', inline='4H')
  389.  
  390. var pdhtext = GlobalTextType or DailyTextType ? 'PDH' : 'Prev Day High'
  391. var pdltext = GlobalTextType or DailyTextType ? 'PDL' : 'Prev Day Low'
  392. var dotext = GlobalTextType or DailyTextType ? 'DO' : 'Daily Open'
  393. var pdmtext = GlobalTextType or DailyTextType ? 'PDM' : 'Prev Day Mid'
  394.  
  395. var pwhtext = GlobalTextType or WeeklyTextType ? 'PWH' : 'Prev Week High'
  396. var pwltext = GlobalTextType or WeeklyTextType ? 'PWL' : 'Prev Week Low'
  397. var wotext = GlobalTextType or WeeklyTextType ? 'WO' : 'Weekly Open'
  398. var pwmtext = GlobalTextType or WeeklyTextType ? 'PWM' : 'Prev Week Mid'
  399.  
  400. var pmhtext = GlobalTextType or MonthlyTextType ? 'PMH' : 'Prev Month High'
  401. var pmltext = GlobalTextType or MonthlyTextType ? 'PML' : 'Prev Month Low'
  402. var motext = GlobalTextType or MonthlyTextType ? 'MO' : 'Monthly Open'
  403. var pmmtext = GlobalTextType or MonthlyTextType ? 'PMM' : 'Prev Month Mid'
  404.  
  405. var pqhtext = GlobalTextType or QuarterlyTextType ? 'PQH' : 'Prev Quarter High'
  406. var pqltext = GlobalTextType or QuarterlyTextType ? 'PQL' : 'Prev Quarter Low'
  407. var qotext = GlobalTextType or QuarterlyTextType ? 'QO' : 'Quarterly Open'
  408. var pqmtext = GlobalTextType or QuarterlyTextType ? 'PQM' : 'Prev Quarter Mid'
  409.  
  410. var cyhtext = GlobalTextType or YearlyTextType ? 'CYH' : 'Current Year High'
  411. var cyltext = GlobalTextType or YearlyTextType ? 'CYL' : 'Current Year Low'
  412. var yotext = GlobalTextType or YearlyTextType ? 'YO' : 'Yearly Open'
  413. var cymtext = GlobalTextType or YearlyTextType ? 'CYM' : 'Current Year Mid'
  414.  
  415. var pihtext = GlobalTextType or IntraTextType ? 'P-4H-H' : 'Prev 4H High'
  416. var piltext = GlobalTextType or IntraTextType ? 'P-4H-L' : 'Prev 4H Low'
  417. var iotext = GlobalTextType or IntraTextType ? '4H-O' : '4H Open'
  418. var pimtext = GlobalTextType or IntraTextType ? 'P-4H-M' : 'Prev 4H Mid'
  419.  
  420. var pmonhtext = GlobalTextType or MondayTextType ? 'MDAY-H' : 'Monday High'
  421. var pmonltext = GlobalTextType or MondayTextType ? 'MDAY-L' : 'Monday Low'
  422. var pmonmtext = GlobalTextType or MondayTextType ? 'MDAY-M' : 'Monday Mid'
  423.  
  424. var lhtext = GlobalTextType or SessionTextType ? 'Lon-H' : 'London High'
  425. var lltext = GlobalTextType or SessionTextType ? 'Lon-L' : 'London Low'
  426. var lotext = GlobalTextType or SessionTextType ? 'Lon-O' : 'London Open'
  427.  
  428.  
  429. var ushtext = GlobalTextType or SessionTextType ? 'NY-H' : 'New York High'
  430. var usltext = GlobalTextType or SessionTextType ? 'NY-L' : 'New York Low'
  431. var usotext = GlobalTextType or SessionTextType ? 'NY-O' : 'New York Open'
  432.  
  433. var asiahtext = GlobalTextType or SessionTextType ? 'AS-H' : 'Asia High'
  434. var asialtext = GlobalTextType or SessionTextType ? 'AS-L' : 'Asia Low'
  435. var asiaotext = GlobalTextType or SessionTextType ? 'AS-O' : 'Asia Open'
  436.  
  437. if globalcoloring == true
  438. DailyColor := GlobalColor
  439. MondayColor := GlobalColor
  440. WeeklyColor := GlobalColor
  441. MonthlyColor := GlobalColor
  442. YearlyColor := GlobalColor
  443. quarterlyColor := GlobalColor
  444. IntraColor := GlobalColor
  445. IntraColor
  446.  
  447.  
  448. if weekly_time != weekly_time[1]
  449. untested_monday := false
  450. untested_monday
  451.  
  452. if is_monday_enabled == true and untested_monday == false
  453. untested_monday := true
  454. monday_time := daily_time
  455. monday_high := cdailyh_open
  456. monday_low := cdailyl_open
  457. monday_low
  458.  
  459.  
  460. linewidthint = 1
  461. if linesize == 'Small'
  462. linewidthint := 1
  463. linewidthint
  464. if linesize == 'Medium'
  465. linewidthint := 2
  466. linewidthint
  467. if linesize == 'Large'
  468. linewidthint := 3
  469. linewidthint
  470.  
  471. var DEFAULT_LINE_WIDTH = linewidthint
  472. var DEFAULT_TAIL_WIDTH = linewidthint
  473.  
  474. fontsize = size.small
  475.  
  476. if labelsize == 'Small'
  477. fontsize := size.small
  478. fontsize
  479.  
  480. if labelsize == 'Medium'
  481. fontsize := size.normal
  482. fontsize
  483.  
  484. if labelsize == 'Large'
  485. fontsize := size.large
  486. fontsize
  487.  
  488. linestyles = line.style_solid
  489. if linestyle == 'Dashed'
  490. linestyles := line.style_dashed
  491. linestyles
  492.  
  493. if linestyle == 'Dotted'
  494. linestyles := line.style_dotted
  495. linestyles
  496.  
  497.  
  498.  
  499. var DEFAULT_LABEL_SIZE = fontsize
  500. var DEFAULT_LABEL_STYLE = label.style_none
  501. var DEFAULT_EXTEND_RIGHT = distanceright
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509. London = time(timeframe.period, Londont)
  510. US = time(timeframe.period, USt)
  511. Asia = time(timeframe.period, Asiat)
  512.  
  513. var clondonhigh = 0.0
  514. var clondonlow = close
  515. var londontime = time
  516. var flondonhigh = 0.0
  517. var flondonlow = 0.0
  518. var flondonopen = 0.0
  519.  
  520. var onelondonfalse = false
  521. if London
  522. if high > clondonhigh
  523. clondonhigh := high
  524. clondonhigh
  525. if low < clondonlow
  526. clondonlow := low
  527. clondonlow
  528. if onelondonfalse
  529. londontime := time
  530. flondonopen := open
  531. flondonopen
  532. flondonhigh := clondonhigh
  533. flondonlow := clondonlow
  534. onelondonfalse := false
  535. onelondonfalse
  536. else
  537. if onelondonfalse == false
  538. flondonhigh := clondonhigh
  539. flondonlow := clondonlow
  540. flondonlow
  541. onelondonfalse := true
  542.  
  543. clondonhigh := 0.0
  544. clondonlow := close
  545. clondonlow
  546.  
  547. //////////////////////////////////
  548. var cushigh = 0.0
  549. var cuslow = close
  550. var ustime = time
  551. var fushigh = 0.0
  552. var fuslow = 0.0
  553. var fusopen = 0.0
  554.  
  555. var oneusfalse = false
  556. if US
  557. if high > cushigh
  558. cushigh := high
  559. cushigh
  560. if low < cuslow
  561. cuslow := low
  562. cuslow
  563. if oneusfalse
  564. ustime := time
  565. fusopen := open
  566. fusopen
  567. fushigh := cushigh
  568. fuslow := cuslow
  569. oneusfalse := false
  570. oneusfalse
  571. else
  572. if oneusfalse == false
  573. fushigh := cushigh
  574. fuslow := cuslow
  575. fuslow
  576. oneusfalse := true
  577.  
  578. cushigh := 0.0
  579. cuslow := close
  580. cuslow
  581.  
  582. //////////////////////////////////
  583. var casiahigh = 0.0
  584. var casialow = close
  585. var asiatime = time
  586. var fasiahigh = 0.0
  587. var fasialow = 0.0
  588. var fasiaopen = 0.0
  589.  
  590. var oneasiafalse = false
  591. if Asia
  592. if high > casiahigh
  593. casiahigh := high
  594. casiahigh
  595. if low < casialow
  596. casialow := low
  597. casialow
  598. if oneasiafalse
  599. asiatime := time
  600. fasiaopen := open
  601. fasiaopen
  602. fasiahigh := casiahigh
  603. fasialow := casialow
  604. oneasiafalse := false
  605. oneasiafalse
  606. else
  607. if oneasiafalse == false
  608. fasiahigh := casiahigh
  609. fasialow := casialow
  610. fasialow
  611. oneasiafalse := true
  612.  
  613. casiahigh := 0.0
  614. casialow := close
  615. casialow
  616.  
  617. //------------------------------ Plotting ------------------------------
  618. var pricearray = array.new_float(0)
  619. var labelarray = array.new_label(0)
  620. f_LevelMerge(pricearray, labelarray, currentprice, currentlabel, currentcolor) =>
  621. if array.includes(pricearray, currentprice)
  622. whichindex = array.indexof(pricearray, currentprice)
  623. labelhold = array.get(labelarray, whichindex)
  624. whichtext = label.get_text(labelhold)
  625.  
  626. label.set_text(labelhold, label.get_text(currentlabel) + ' / ' + whichtext)
  627. label.set_text(currentlabel, '')
  628. label.set_textcolor(labelhold, currentcolor)
  629. else
  630. array.push(pricearray, currentprice)
  631. array.push(labelarray, currentlabel)
  632.  
  633.  
  634. var can_show_daily = is_daily_enabled and timeframe.isintraday
  635. var can_show_weekly = is_weekly_enabled and not timeframe.isweekly and not timeframe.ismonthly
  636. var can_show_monthly = is_monthly_enabled and not timeframe.ismonthly
  637.  
  638. get_limit_right(bars) =>
  639. timenow + (time - time[1]) * bars
  640.  
  641. // the following code doesn't need to be processed on every candle
  642. if barstate.islast
  643. is_weekly_open = dayofweek == dayofweek.monday
  644. is_monthly_open = dayofmonth == 1
  645. can_draw_daily = (is_weekly_enabled ? not is_weekly_open : true) and (is_monthly_enabled ? not is_monthly_open : true)
  646. can_draw_weekly = is_monthly_enabled ? not(is_monthly_open and is_weekly_open) : true
  647. can_draw_intra = is_intra_enabled
  648. can_draw_intrah = is_intrarange_enabled
  649. can_draw_intral = is_intrarange_enabled
  650. can_draw_intram = is_intram_enabled
  651. pricearray := array.new_float(0)
  652. labelarray := array.new_label(0)
  653.  
  654. /////////////////////////////////
  655.  
  656. if is_londonrange_enabled
  657. //label.new(bar_index,high)
  658. london_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  659.  
  660.  
  661. if displayStyle == 'Right Anchored'
  662. londontime := get_limit_right(radistance)
  663. londontime
  664.  
  665. var londonh_line = line.new(x1=londontime, x2=london_limit_right, y1=flondonhigh, y2=flondonhigh, color=LondonColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  666. var londonl_line = line.new(x1=londontime, x2=london_limit_right, y1=flondonlow, y2=flondonlow, color=LondonColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  667. var londono_line = line.new(x1=londontime, x2=london_limit_right, y1=flondonopen, y2=flondonopen, color=LondonColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  668. var londonh_label = label.new(x=london_limit_right, y=flondonhigh, text=lhtext, style=DEFAULT_LABEL_STYLE, textcolor=LondonColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  669. var londonl_label = label.new(x=london_limit_right, y=flondonlow, text=lltext, style=DEFAULT_LABEL_STYLE, textcolor=LondonColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  670. var londono_label = label.new(x=london_limit_right, y=flondonopen, text=lotext, style=DEFAULT_LABEL_STYLE, textcolor=LondonColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  671. line.set_x1(londonh_line, londontime)
  672. line.set_x2(londonh_line, london_limit_right)
  673. line.set_y1(londonh_line, flondonhigh)
  674. line.set_y2(londonh_line, flondonhigh)
  675. line.set_x1(londonl_line, londontime)
  676. line.set_x2(londonl_line, london_limit_right)
  677. line.set_y1(londonl_line, flondonlow)
  678. line.set_y2(londonl_line, flondonlow)
  679. line.set_x1(londono_line, londontime)
  680. line.set_x2(londono_line, london_limit_right)
  681. line.set_y1(londono_line, flondonopen)
  682. line.set_y2(londono_line, flondonopen)
  683.  
  684. label.set_x(londonh_label, london_limit_right)
  685. label.set_y(londonh_label, flondonhigh)
  686. label.set_text(londonh_label, lhtext)
  687. label.set_x(londonl_label, london_limit_right)
  688. label.set_y(londonl_label, flondonlow)
  689. label.set_text(londonl_label, lltext)
  690. label.set_x(londono_label, london_limit_right)
  691. label.set_y(londono_label, flondonopen)
  692. label.set_text(londono_label, lotext)
  693.  
  694. if mergebool
  695. f_LevelMerge(pricearray, labelarray, flondonhigh, londonh_label, LondonColor)
  696. f_LevelMerge(pricearray, labelarray, flondonlow, londonl_label, LondonColor)
  697. f_LevelMerge(pricearray, labelarray, flondonopen, londono_label, LondonColor)
  698. //////////////////////////////////////////////////////////////////////////////////
  699. /////////////////////////////////
  700.  
  701. if is_usrange_enabled
  702. //label.new(bar_index,high)
  703. us_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  704.  
  705.  
  706. if displayStyle == 'Right Anchored'
  707. ustime := get_limit_right(radistance)
  708. ustime
  709.  
  710. var ush_line = line.new(x1=ustime, x2=us_limit_right, y1=fushigh, y2=fushigh, color=USColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  711. var usl_line = line.new(x1=ustime, x2=us_limit_right, y1=fuslow, y2=fuslow, color=USColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  712. var uso_line = line.new(x1=ustime, x2=us_limit_right, y1=fusopen, y2=fusopen, color=USColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  713. var ush_label = label.new(x=us_limit_right, y=fushigh, text=lhtext, style=DEFAULT_LABEL_STYLE, textcolor=USColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  714. var usl_label = label.new(x=us_limit_right, y=fuslow, text=lltext, style=DEFAULT_LABEL_STYLE, textcolor=USColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  715. var uso_label = label.new(x=us_limit_right, y=fusopen, text=lotext, style=DEFAULT_LABEL_STYLE, textcolor=USColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  716. line.set_x1(ush_line, ustime)
  717. line.set_x2(ush_line, us_limit_right)
  718. line.set_y1(ush_line, fushigh)
  719. line.set_y2(ush_line, fushigh)
  720.  
  721. line.set_x1(usl_line, ustime)
  722. line.set_x2(usl_line, us_limit_right)
  723. line.set_y1(usl_line, fuslow)
  724. line.set_y2(usl_line, fuslow)
  725.  
  726. line.set_x1(uso_line, ustime)
  727. line.set_x2(uso_line, us_limit_right)
  728. line.set_y1(uso_line, fusopen)
  729. line.set_y2(uso_line, fusopen)
  730.  
  731.  
  732. label.set_x(ush_label, us_limit_right)
  733. label.set_y(ush_label, fushigh)
  734. label.set_text(ush_label, ushtext)
  735. label.set_x(usl_label, us_limit_right)
  736. label.set_y(usl_label, fuslow)
  737. label.set_text(usl_label, usltext)
  738. label.set_x(uso_label, us_limit_right)
  739. label.set_y(uso_label, fusopen)
  740. label.set_text(uso_label, usotext)
  741. if mergebool
  742. f_LevelMerge(pricearray, labelarray, fushigh, ush_label, USColor)
  743. f_LevelMerge(pricearray, labelarray, fuslow, usl_label, USColor)
  744. f_LevelMerge(pricearray, labelarray, fusopen, uso_label, USColor)
  745. /////////////////////////////////
  746.  
  747. if is_asiarange_enabled
  748. //label.new(bar_index,high)
  749. asia_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  750.  
  751.  
  752. if displayStyle == 'Right Anchored'
  753. asiatime := get_limit_right(radistance)
  754. asiatime
  755.  
  756. var asiah_line = line.new(x1=asiatime, x2=asia_limit_right, y1=fasiahigh, y2=fasiahigh, color=AsiaColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  757. var asial_line = line.new(x1=asiatime, x2=asia_limit_right, y1=fasialow, y2=fasialow, color=AsiaColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  758. var asiao_line = line.new(x1=asiatime, x2=asia_limit_right, y1=fasiaopen, y2=fasiaopen, color=AsiaColor, width=DEFAULT_LINE_WIDTH, xloc=xloc.bar_time, style=linestyles)
  759. var asiah_label = label.new(x=asia_limit_right, y=fasiahigh, text=asiahtext, style=DEFAULT_LABEL_STYLE, textcolor=AsiaColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  760. var asial_label = label.new(x=asia_limit_right, y=fasialow, text=asialtext, style=DEFAULT_LABEL_STYLE, textcolor=AsiaColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  761. var asiao_label = label.new(x=asia_limit_right, y=fasiaopen, text=asiaotext, style=DEFAULT_LABEL_STYLE, textcolor=AsiaColor, size=DEFAULT_LABEL_SIZE, xloc=xloc.bar_time)
  762. line.set_x1(asiah_line, asiatime)
  763. line.set_x2(asiah_line, asia_limit_right)
  764. line.set_y1(asiah_line, fasiahigh)
  765. line.set_y2(asiah_line, fasiahigh)
  766.  
  767. line.set_x1(asial_line, asiatime)
  768. line.set_x2(asial_line, asia_limit_right)
  769. line.set_y1(asial_line, fasialow)
  770. line.set_y2(asial_line, fasialow)
  771.  
  772. line.set_x1(asiao_line, asiatime)
  773. line.set_x2(asiao_line, asia_limit_right)
  774. line.set_y1(asiao_line, fasiaopen)
  775. line.set_y2(asiao_line, fasiaopen)
  776.  
  777.  
  778. label.set_x(asiah_label, asia_limit_right)
  779. label.set_y(asiah_label, fasiahigh)
  780. label.set_text(asiah_label, asiahtext)
  781. label.set_x(asial_label, asia_limit_right)
  782. label.set_y(asial_label, fasialow)
  783. label.set_text(asial_label, asialtext)
  784. label.set_x(asiao_label, asia_limit_right)
  785. label.set_y(asiao_label, fasiaopen)
  786. label.set_text(asiao_label, asiaotext)
  787. if mergebool
  788. f_LevelMerge(pricearray, labelarray, fasiahigh, asiah_label, AsiaColor)
  789. f_LevelMerge(pricearray, labelarray, fasialow, asial_label, AsiaColor)
  790. f_LevelMerge(pricearray, labelarray, fasiaopen, asiao_label, AsiaColor)
  791. //////////////////////////////////////////////////////////////////////////////////
  792.  
  793. //////////////////////////////////////////////////////////////////////////////////
  794. if can_draw_intra
  795. intra_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  796. if displayStyle == 'Right Anchored'
  797. intra_time := get_limit_right(radistance)
  798. intra_time
  799.  
  800.  
  801. 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)
  802. 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)
  803.  
  804. line.set_x1(intra_line, intra_time)
  805. line.set_x2(intra_line, intra_limit_right)
  806. line.set_y1(intra_line, intra_open)
  807. line.set_y2(intra_line, intra_open)
  808. label.set_x(intra_label, intra_limit_right)
  809. label.set_y(intra_label, intra_open)
  810. label.set_text(intra_label, iotext)
  811. if mergebool
  812. f_LevelMerge(pricearray, labelarray, intra_open, intra_label, IntraColor)
  813.  
  814.  
  815. //////////////////////////////////////////////////////////////////////////////////
  816. //HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH HIGH
  817. if can_draw_intrah
  818. intrah_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  819. if displayStyle == 'Right Anchored'
  820. intrah_time := get_limit_right(radistance)
  821. intrah_time
  822.  
  823.  
  824.  
  825. 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)
  826. 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)
  827.  
  828. line.set_x1(intrah_line, intrah_time)
  829. line.set_x2(intrah_line, intrah_limit_right)
  830. line.set_y1(intrah_line, intrah_open)
  831. line.set_y2(intrah_line, intrah_open)
  832. label.set_x(intrah_label, intrah_limit_right)
  833. label.set_y(intrah_label, intrah_open)
  834. label.set_text(intrah_label, pihtext)
  835. if mergebool
  836. f_LevelMerge(pricearray, labelarray, intrah_open, intrah_label, IntraColor)
  837.  
  838. //////////////////////////////////////////////////////////////////////////////////
  839. //LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW LOW
  840. if can_draw_intral
  841. intral_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  842. if displayStyle == 'Right Anchored'
  843. intral_time := get_limit_right(radistance)
  844. intral_time
  845.  
  846.  
  847.  
  848. 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)
  849. 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)
  850.  
  851. line.set_x1(intral_line, intral_time)
  852. line.set_x2(intral_line, intral_limit_right)
  853. line.set_y1(intral_line, intral_open)
  854. line.set_y2(intral_line, intral_open)
  855. label.set_x(intral_label, intral_limit_right)
  856. label.set_y(intral_label, intral_open)
  857. label.set_text(intral_label, piltext)
  858. if mergebool
  859. f_LevelMerge(pricearray, labelarray, intral_open, intral_label, IntraColor)
  860.  
  861. ///////////////////////////////////////////////////////////////////////////////
  862.  
  863. if can_draw_intram
  864. intram_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  865. intram_time = intrah_time
  866. intram_open = (intral_open + intrah_open) / 2
  867. if displayStyle == 'Right Anchored'
  868. intram_time := get_limit_right(radistance)
  869. intram_time
  870.  
  871. 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)
  872. 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)
  873. line.set_x1(intram_line, intram_time)
  874. line.set_x2(intram_line, intram_limit_right)
  875. line.set_y1(intram_line, intram_open)
  876. line.set_y2(intram_line, intram_open)
  877. label.set_x(intram_label, intram_limit_right)
  878. label.set_y(intram_label, intram_open)
  879. label.set_text(intram_label, pimtext)
  880. if mergebool
  881. f_LevelMerge(pricearray, labelarray, intram_open, intram_label, IntraColor)
  882.  
  883. ////////////////////////////////////////// MONDAY
  884.  
  885. if is_monday_enabled
  886. monday_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  887. if displayStyle == 'Right Anchored'
  888. monday_time := get_limit_right(radistance)
  889. monday_time
  890.  
  891. 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)
  892. 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)
  893.  
  894. line.set_x1(monday_line, monday_time)
  895. line.set_x2(monday_line, monday_limit_right)
  896. line.set_y1(monday_line, monday_high)
  897. line.set_y2(monday_line, monday_high)
  898. label.set_x(monday_label, monday_limit_right)
  899. label.set_y(monday_label, monday_high)
  900. label.set_text(monday_label, pmonhtext)
  901. if mergebool
  902. f_LevelMerge(pricearray, labelarray, monday_high, monday_label, MondayColor)
  903.  
  904.  
  905. if is_monday_enabled
  906. monday_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  907. if displayStyle == 'Right Anchored'
  908. monday_time := get_limit_right(radistance)
  909. monday_time
  910.  
  911.  
  912.  
  913. 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)
  914. 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)
  915.  
  916. line.set_x1(monday_low_line, monday_time)
  917. line.set_x2(monday_low_line, monday_limit_right)
  918. line.set_y1(monday_low_line, monday_low)
  919. line.set_y2(monday_low_line, monday_low)
  920. label.set_x(monday_low_label, monday_limit_right)
  921. label.set_y(monday_low_label, monday_low)
  922. label.set_text(monday_low_label, pmonltext)
  923. if mergebool
  924. f_LevelMerge(pricearray, labelarray, monday_low, monday_low_label, MondayColor)
  925.  
  926.  
  927.  
  928. if is_monday_mid
  929. mondaym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  930.  
  931. mondaym_open = (monday_high + monday_low) / 2
  932. if displayStyle == 'Right Anchored'
  933. monday_time := get_limit_right(radistance)
  934. monday_time
  935.  
  936. 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)
  937. 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)
  938. line.set_x1(mondaym_line, monday_time)
  939. line.set_x2(mondaym_line, mondaym_limit_right)
  940. line.set_y1(mondaym_line, mondaym_open)
  941. line.set_y2(mondaym_line, mondaym_open)
  942. label.set_x(mondaym_label, mondaym_limit_right)
  943. label.set_y(mondaym_label, mondaym_open)
  944. label.set_text(mondaym_label, pmonmtext)
  945. if mergebool
  946. f_LevelMerge(pricearray, labelarray, mondaym_open, mondaym_label, MondayColor)
  947.  
  948.  
  949. //////////////////////////////////////////////////////////////////////////////////
  950. ////////////////////////DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN DAILY OPEN
  951.  
  952. if is_daily_enabled
  953. daily_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  954. if displayStyle == 'Right Anchored'
  955. daily_time := get_limit_right(radistance)
  956. daily_time
  957.  
  958. 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)
  959. 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)
  960.  
  961. line.set_x1(daily_line, daily_time)
  962. line.set_x2(daily_line, daily_limit_right)
  963. line.set_y1(daily_line, daily_open)
  964. line.set_y2(daily_line, daily_open)
  965. label.set_x(daily_label, daily_limit_right)
  966. label.set_y(daily_label, daily_open)
  967. label.set_text(daily_label, dotext)
  968. if mergebool
  969. f_LevelMerge(pricearray, labelarray, daily_open, daily_label, DailyColor)
  970.  
  971. //////////////////////////////////////////////////////////////////////////////////
  972. //////////////////DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH DAILY HIGH
  973.  
  974. if is_dailyrange_enabled
  975. dailyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  976. if displayStyle == 'Right Anchored'
  977. dailyh_time := get_limit_right(radistance)
  978. dailyh_time
  979. // draw tails before lines for better visual
  980.  
  981.  
  982. 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)
  983. 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)
  984.  
  985. line.set_x1(dailyh_line, dailyh_time)
  986. line.set_x2(dailyh_line, dailyh_limit_right)
  987. line.set_y1(dailyh_line, dailyh_open)
  988. line.set_y2(dailyh_line, dailyh_open)
  989. label.set_x(dailyh_label, dailyh_limit_right)
  990. label.set_y(dailyh_label, dailyh_open)
  991. label.set_text(dailyh_label, pdhtext)
  992. if mergebool
  993. f_LevelMerge(pricearray, labelarray, dailyh_open, dailyh_label, DailyColor)
  994.  
  995.  
  996. //////////////////////////////////////////////////////////////////////////////////
  997. //////////////////DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW DAILY LOW
  998.  
  999. if is_dailyrange_enabled
  1000. dailyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1001. if displayStyle == 'Right Anchored'
  1002. dailyl_time := get_limit_right(radistance)
  1003. dailyl_time
  1004.  
  1005.  
  1006. 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)
  1007. 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)
  1008.  
  1009. line.set_x1(dailyl_line, dailyl_time)
  1010. line.set_x2(dailyl_line, dailyl_limit_right)
  1011. line.set_y1(dailyl_line, dailyl_open)
  1012. line.set_y2(dailyl_line, dailyl_open)
  1013. label.set_x(dailyl_label, dailyl_limit_right)
  1014. label.set_y(dailyl_label, dailyl_open)
  1015. label.set_text(dailyl_label, pdltext)
  1016. if mergebool
  1017. f_LevelMerge(pricearray, labelarray, dailyl_open, dailyl_label, DailyColor)
  1018.  
  1019.  
  1020.  
  1021. //////////////////////////////////////////////////////////////////////////////// Daily MID
  1022.  
  1023. if is_dailym_enabled
  1024. dailym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1025. dailym_time = dailyh_time
  1026. dailym_open = (dailyl_open + dailyh_open) / 2
  1027. if displayStyle == 'Right Anchored'
  1028. dailym_time := get_limit_right(radistance)
  1029. dailym_time
  1030. 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)
  1031. 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)
  1032. line.set_x1(dailym_line, dailym_time)
  1033. line.set_x2(dailym_line, dailym_limit_right)
  1034. line.set_y1(dailym_line, dailym_open)
  1035. line.set_y2(dailym_line, dailym_open)
  1036. label.set_x(dailym_label, dailym_limit_right)
  1037. label.set_y(dailym_label, dailym_open)
  1038. label.set_text(dailym_label, pdmtext)
  1039. if mergebool
  1040. f_LevelMerge(pricearray, labelarray, dailym_open, dailym_label, DailyColor)
  1041.  
  1042.  
  1043. //////////////////////////////////////////////////////////////////////////////////
  1044.  
  1045.  
  1046. if is_weekly_enabled
  1047. weekly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1048. cweekly_time = weekly_time
  1049. if displayStyle == 'Right Anchored'
  1050. cweekly_time := get_limit_right(radistance)
  1051. cweekly_time
  1052.  
  1053.  
  1054. 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)
  1055. 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)
  1056.  
  1057. line.set_x1(weekly_line, cweekly_time)
  1058. line.set_x2(weekly_line, weekly_limit_right)
  1059. line.set_y1(weekly_line, weekly_open)
  1060. line.set_y2(weekly_line, weekly_open)
  1061. label.set_x(weekly_label, weekly_limit_right)
  1062. label.set_y(weekly_label, weekly_open)
  1063. label.set_text(weekly_label, wotext)
  1064. if mergebool
  1065. f_LevelMerge(pricearray, labelarray, weekly_open, weekly_label, WeeklyColor)
  1066. // the weekly open can be the daily open too (monday)
  1067. // only the weekly will be draw, in these case we update its label
  1068. // if is_weekly_open and can_show_daily
  1069. // label.set_text(weekly_label, "DO / WO ")
  1070.  
  1071. //////////////////////////////////////////////////////////////////////////////////
  1072. ////////////////////////////////////////////////////////////////////////////////// WEEKLY HIGH WEEKLY HIGH WEEKLY HIGH
  1073.  
  1074.  
  1075. if is_weeklyrange_enabled
  1076. weeklyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1077. if displayStyle == 'Right Anchored'
  1078. weeklyh_time := get_limit_right(radistance)
  1079. weeklyh_time
  1080.  
  1081.  
  1082. 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)
  1083. 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)
  1084.  
  1085. line.set_x1(weeklyh_line, weeklyh_time)
  1086. line.set_x2(weeklyh_line, weeklyh_limit_right)
  1087. line.set_y1(weeklyh_line, weeklyh_open)
  1088. line.set_y2(weeklyh_line, weeklyh_open)
  1089. label.set_x(weeklyh_label, weeklyh_limit_right)
  1090. label.set_y(weeklyh_label, weeklyh_open)
  1091. label.set_text(weeklyh_label, pwhtext)
  1092. if mergebool
  1093. f_LevelMerge(pricearray, labelarray, weeklyh_open, weeklyh_label, WeeklyColor)
  1094.  
  1095. //////////////////////////////////////////////////////////////////////////////////
  1096. ////////////////////////////////////////////////////////////////////////////////// WEEKLY LOW WEEKLY LOW WEEKLY LOW
  1097.  
  1098.  
  1099. if is_weeklyrange_enabled
  1100. weeklyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1101. if displayStyle == 'Right Anchored'
  1102. weeklyl_time := get_limit_right(radistance)
  1103. weeklyl_time
  1104.  
  1105.  
  1106. 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)
  1107. 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)
  1108.  
  1109. line.set_x1(weeklyl_line, weeklyl_time)
  1110. line.set_x2(weeklyl_line, weeklyl_limit_right)
  1111. line.set_y1(weeklyl_line, weeklyl_open)
  1112. line.set_y2(weeklyl_line, weeklyl_open)
  1113. label.set_x(weeklyl_label, weeklyl_limit_right)
  1114. label.set_y(weeklyl_label, weeklyl_open)
  1115. label.set_text(weeklyl_label, pwltext)
  1116. if mergebool
  1117. f_LevelMerge(pricearray, labelarray, weeklyl_open, weeklyl_label, WeeklyColor)
  1118.  
  1119.  
  1120.  
  1121. //////////////////////////////////////////////////////////////////////////////////
  1122. //////////////////////////////////////////////////////////////////////////////// Weekly MID
  1123.  
  1124. if is_weekly_mid
  1125. weeklym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1126. weeklym_time = weeklyh_time
  1127. weeklym_open = (weeklyl_open + weeklyh_open) / 2
  1128. if displayStyle == 'Right Anchored'
  1129. weeklym_time := get_limit_right(radistance)
  1130. weeklym_time
  1131.  
  1132. 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)
  1133. 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)
  1134. line.set_x1(weeklym_line, weeklym_time)
  1135. line.set_x2(weeklym_line, weeklym_limit_right)
  1136. line.set_y1(weeklym_line, weeklym_open)
  1137. line.set_y2(weeklym_line, weeklym_open)
  1138. label.set_x(weeklym_label, weeklym_limit_right)
  1139. label.set_y(weeklym_label, weeklym_open)
  1140. label.set_text(weeklym_label, pwmtext)
  1141. if mergebool
  1142. f_LevelMerge(pricearray, labelarray, weeklym_open, weeklym_label, WeeklyColor)
  1143. ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY LOW LOW LOW
  1144.  
  1145.  
  1146. if is_yearlyrange_enabled
  1147. yearlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1148. if displayStyle == 'Right Anchored'
  1149. yearlyl_time := get_limit_right(radistance)
  1150. yearlyl_time
  1151.  
  1152.  
  1153. 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)
  1154. 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)
  1155.  
  1156. line.set_x1(yearlyl_line, yearlyl_time)
  1157. line.set_x2(yearlyl_line, yearlyl_limit_right)
  1158. line.set_y1(yearlyl_line, yearlyl_open)
  1159. line.set_y2(yearlyl_line, yearlyl_open)
  1160. label.set_x(yearlyl_label, yearlyl_limit_right)
  1161. label.set_y(yearlyl_label, yearlyl_open)
  1162. label.set_text(yearlyl_label, cyltext)
  1163. if mergebool
  1164. f_LevelMerge(pricearray, labelarray, yearlyl_open, yearlyl_label, YearlyColor)
  1165.  
  1166.  
  1167.  
  1168. //////////////////////////////////////////////////////////////////////////////////
  1169.  
  1170.  
  1171. ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY HIGH HIGH HIGH
  1172.  
  1173.  
  1174. if is_yearlyrange_enabled
  1175. yearlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1176. if displayStyle == 'Right Anchored'
  1177. yearlyh_time := get_limit_right(radistance)
  1178. yearlyh_time
  1179.  
  1180.  
  1181. 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)
  1182. 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)
  1183.  
  1184. line.set_x1(yearlyh_line, yearlyh_time)
  1185. line.set_x2(yearlyh_line, yearlyh_limit_right)
  1186. line.set_y1(yearlyh_line, yearlyh_open)
  1187. line.set_y2(yearlyh_line, yearlyh_open)
  1188. label.set_x(yearlyh_label, yearlyh_limit_right)
  1189. label.set_y(yearlyh_label, yearlyh_open)
  1190. label.set_text(yearlyh_label, cyhtext)
  1191. if mergebool
  1192. f_LevelMerge(pricearray, labelarray, yearlyh_open, yearlyh_label, YearlyColor)
  1193.  
  1194.  
  1195.  
  1196. //////////////////////////////////////////////////////////////////////////////////
  1197.  
  1198. ////////////////////////////////////////////////////////////////////////////////// YEEEAARRLLYY OPEN
  1199.  
  1200.  
  1201. if is_yearly_enabled
  1202. yearly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1203. if displayStyle == 'Right Anchored'
  1204. yearly_time := get_limit_right(radistance)
  1205. yearly_time
  1206.  
  1207.  
  1208. 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)
  1209.  
  1210. 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)
  1211.  
  1212.  
  1213.  
  1214. line.set_x1(yearly_line, yearly_time)
  1215. line.set_x2(yearly_line, yearly_limit_right)
  1216. line.set_y1(yearly_line, yearly_open)
  1217. line.set_y2(yearly_line, yearly_open)
  1218. label.set_x(yearly_label, yearly_limit_right)
  1219. label.set_y(yearly_label, yearly_open)
  1220. label.set_text(yearly_label, yotext)
  1221. if mergebool
  1222. f_LevelMerge(pricearray, labelarray, yearly_open, yearly_label, YearlyColor)
  1223.  
  1224.  
  1225.  
  1226. //////////////////////////////////////////////////////////////////////////////////
  1227. //////////////////////////////////////////////////////////////////////////////// yearly MID
  1228.  
  1229. if is_yearly_mid
  1230. yearlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1231. yearlym_time = yearlyh_time
  1232. yearlym_open = (yearlyl_open + yearlyh_open) / 2
  1233. if displayStyle == 'Right Anchored'
  1234. yearlym_time := get_limit_right(radistance)
  1235. yearlym_time
  1236.  
  1237. 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)
  1238. 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)
  1239. line.set_x1(yearlym_line, yearlym_time)
  1240. line.set_x2(yearlym_line, yearlym_limit_right)
  1241. line.set_y1(yearlym_line, yearlym_open)
  1242. line.set_y2(yearlym_line, yearlym_open)
  1243. label.set_x(yearlym_label, yearlym_limit_right)
  1244. label.set_y(yearlym_label, yearlym_open)
  1245. label.set_text(yearlym_label, cymtext)
  1246. if mergebool
  1247. f_LevelMerge(pricearray, labelarray, yearlym_open, yearlym_label, YearlyColor)
  1248.  
  1249.  
  1250. ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY OPEN
  1251.  
  1252.  
  1253. if is_quarterly_enabled
  1254. quarterly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1255. if displayStyle == 'Right Anchored'
  1256. quarterly_time := get_limit_right(radistance)
  1257. quarterly_time
  1258.  
  1259.  
  1260. 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)
  1261. 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)
  1262.  
  1263. line.set_x1(quarterly_line, quarterly_time)
  1264. line.set_x2(quarterly_line, quarterly_limit_right)
  1265. line.set_y1(quarterly_line, quarterly_open)
  1266. line.set_y2(quarterly_line, quarterly_open)
  1267. label.set_x(quarterly_label, quarterly_limit_right)
  1268. label.set_y(quarterly_label, quarterly_open)
  1269. label.set_text(quarterly_label, qotext)
  1270. if mergebool
  1271. f_LevelMerge(pricearray, labelarray, quarterly_open, quarterly_label, quarterlyColor)
  1272.  
  1273.  
  1274.  
  1275. //////////////////////////////////////////////////////////////////////////////////
  1276.  
  1277.  
  1278. ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY High
  1279.  
  1280.  
  1281. if is_quarterlyrange_enabled
  1282. quarterlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1283. if displayStyle == 'Right Anchored'
  1284. quarterlyh_time := get_limit_right(radistance)
  1285. quarterlyh_time
  1286.  
  1287.  
  1288. 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)
  1289. 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)
  1290.  
  1291. line.set_x1(quarterlyh_line, quarterlyh_time)
  1292. line.set_x2(quarterlyh_line, quarterlyh_limit_right)
  1293. line.set_y1(quarterlyh_line, quarterlyh_open)
  1294. line.set_y2(quarterlyh_line, quarterlyh_open)
  1295. label.set_x(quarterlyh_label, quarterlyh_limit_right)
  1296. label.set_y(quarterlyh_label, quarterlyh_open)
  1297. label.set_text(quarterlyh_label, pqhtext)
  1298. if mergebool
  1299. f_LevelMerge(pricearray, labelarray, quarterlyh_open, quarterlyh_label, quarterlyColor)
  1300.  
  1301.  
  1302.  
  1303. //////////////////////////////////////////////////////////////////////////////////
  1304.  
  1305.  
  1306. ////////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY Low
  1307.  
  1308.  
  1309. if is_quarterlyrange_enabled
  1310. quarterlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1311. if displayStyle == 'Right Anchored'
  1312. quarterlyl_time := get_limit_right(radistance)
  1313. quarterlyl_time
  1314.  
  1315.  
  1316. 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)
  1317. 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)
  1318.  
  1319. line.set_x1(quarterlyl_line, quarterlyl_time)
  1320. line.set_x2(quarterlyl_line, quarterlyl_limit_right)
  1321. line.set_y1(quarterlyl_line, quarterlyl_open)
  1322. line.set_y2(quarterlyl_line, quarterlyl_open)
  1323. label.set_x(quarterlyl_label, quarterlyl_limit_right)
  1324. label.set_y(quarterlyl_label, quarterlyl_open)
  1325.  
  1326. label.set_text(quarterlyl_label, pqltext)
  1327. if mergebool
  1328. f_LevelMerge(pricearray, labelarray, quarterlyl_open, quarterlyl_label, quarterlyColor)
  1329.  
  1330.  
  1331.  
  1332. //////////////////////////////////////////////////////////////////////////////////
  1333. //////////////////////////////////////////////////////////////////////////////// QUATERLLYYYYY MID
  1334.  
  1335. if is_quarterly_mid
  1336. quarterlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1337. quarterlym_time = quarterlyh_time
  1338. quarterlym_open = (quarterlyl_open + quarterlyh_open) / 2
  1339. if displayStyle == 'Right Anchored'
  1340. quarterlym_time := get_limit_right(radistance)
  1341. quarterlym_time
  1342. 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)
  1343. 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)
  1344. line.set_x1(quarterlym_line, quarterlym_time)
  1345. line.set_x2(quarterlym_line, quarterlym_limit_right)
  1346. line.set_y1(quarterlym_line, quarterlym_open)
  1347. line.set_y2(quarterlym_line, quarterlym_open)
  1348. label.set_x(quarterlym_label, quarterlym_limit_right)
  1349. label.set_y(quarterlym_label, quarterlym_open)
  1350.  
  1351. label.set_text(quarterlym_label, pqmtext)
  1352. if mergebool
  1353. f_LevelMerge(pricearray, labelarray, quarterlym_open, quarterlym_label, quarterlyColor)
  1354.  
  1355. ////////////////////////////////////////////////////////////////////////////////// Monthly LOW LOW LOW
  1356.  
  1357.  
  1358. if is_monthlyrange_enabled
  1359. monthlyl_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1360. if displayStyle == 'Right Anchored'
  1361. monthlyl_time := get_limit_right(radistance)
  1362. monthlyl_time
  1363.  
  1364.  
  1365. 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)
  1366. 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)
  1367.  
  1368. line.set_x1(monthlyl_line, monthlyl_time)
  1369. line.set_x2(monthlyl_line, monthlyl_limit_right)
  1370. line.set_y1(monthlyl_line, monthlyl_open)
  1371. line.set_y2(monthlyl_line, monthlyl_open)
  1372. label.set_x(monthlyl_label, monthlyl_limit_right)
  1373. label.set_y(monthlyl_label, monthlyl_open)
  1374. label.set_text(monthlyl_label, pmltext)
  1375. if mergebool
  1376. f_LevelMerge(pricearray, labelarray, monthlyl_open, monthlyl_label, MonthlyColor)
  1377. // the weekly open can be the daily open too (monday)
  1378. // only the weekly will be draw, in these case we update its label
  1379.  
  1380.  
  1381. //////////////////////////////////////////////////////////////////////////////////
  1382. ////////////////////////////////////////////////////////////////////////////////// MONTHLY HIGH HIGH HIGH
  1383.  
  1384.  
  1385.  
  1386. if is_monthlyrange_enabled
  1387. monthlyh_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1388. if displayStyle == 'Right Anchored'
  1389. monthlyh_time := get_limit_right(radistance)
  1390. monthlyh_time
  1391.  
  1392.  
  1393. 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)
  1394. 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)
  1395.  
  1396. line.set_x1(monthlyh_line, monthlyl_time)
  1397. line.set_x2(monthlyh_line, monthlyh_limit_right)
  1398. line.set_y1(monthlyh_line, monthlyh_open)
  1399. line.set_y2(monthlyh_line, monthlyh_open)
  1400. label.set_x(monthlyh_label, monthlyh_limit_right)
  1401. label.set_y(monthlyh_label, monthlyh_open)
  1402. label.set_text(monthlyh_label, pmhtext)
  1403. if mergebool
  1404. f_LevelMerge(pricearray, labelarray, monthlyh_open, monthlyh_label, MonthlyColor)
  1405. // the weekly open can be the daily open too (monday)
  1406. // only the weekly will be draw, in these case we update its label
  1407.  
  1408. //////////////////////////////////////////////////////////////////////////////// MONTHLY MID
  1409.  
  1410. if is_monthly_mid
  1411. monthlym_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1412. monthlym_time = monthlyh_time
  1413. monthlym_open = (monthlyl_open + monthlyh_open) / 2
  1414. if displayStyle == 'Right Anchored'
  1415. monthlym_time := get_limit_right(radistance)
  1416. monthlym_time
  1417. 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)
  1418. 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)
  1419. line.set_x1(monthlym_line, monthlym_time)
  1420. line.set_x2(monthlym_line, monthlym_limit_right)
  1421. line.set_y1(monthlym_line, monthlym_open)
  1422. line.set_y2(monthlym_line, monthlym_open)
  1423. label.set_x(monthlym_label, monthlym_limit_right)
  1424. label.set_y(monthlym_label, monthlym_open)
  1425. label.set_text(monthlym_label, pmmtext)
  1426. if mergebool
  1427. f_LevelMerge(pricearray, labelarray, monthlym_open, monthlym_label, MonthlyColor)
  1428. //////////////////////////////////////////////////////////////////////////////////
  1429.  
  1430.  
  1431.  
  1432. if is_monthly_enabled
  1433. monthly_limit_right = get_limit_right(DEFAULT_EXTEND_RIGHT)
  1434. if displayStyle == 'Right Anchored'
  1435. monthly_time := get_limit_right(radistance)
  1436. monthly_time
  1437.  
  1438. 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)
  1439. 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)
  1440.  
  1441. line.set_x1(monthlyLine, monthly_time)
  1442. line.set_x2(monthlyLine, monthly_limit_right)
  1443. line.set_y1(monthlyLine, monthly_open)
  1444. line.set_y2(monthlyLine, monthly_open)
  1445. label.set_x(monthlyLabel, monthly_limit_right)
  1446. label.set_y(monthlyLabel, monthly_open)
  1447. label.set_text(monthlyLabel, motext)
  1448. if mergebool
  1449. f_LevelMerge(pricearray, labelarray, monthly_open, monthlyLabel, MonthlyColor)
  1450.  
  1451.  
  1452. /////////////////////////////////////////////////////////////////////////////
  1453.  
  1454. // the monthly open can be the weekly open (monday 1st) and/or daily open too
  1455. // only the monthly will be draw, in these case we update its label
  1456. // if is_monthly_open
  1457. // if can_show_daily
  1458. // label.set_text(monthlyLabel, "DO / MO ")
  1459. // if is_weekly_open
  1460. // if can_show_weekly
  1461. // label.set_text(monthlyLabel, "WO / MO ")
  1462. // if can_show_daily and can_show_weekly
  1463. // label.set_text(monthlyLabel, "DO / WO / MO ")
  1464.  
  1465. // the start of the line is drew from the first week of the month
  1466. // if the first day of the weekly candle (monday) is the 2nd of the month
  1467. // we fix the start of the line position on the Prev weekly candle
  1468. if timeframe.isweekly and dayofweek(monthly_time) != dayofweek.monday
  1469. line.set_x1(monthlyLine, monthly_time - (weekly_time - weekly_time[1]))
  1470.  
  1471. //
  1472.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement