Advertisement
dusun1

CC INDICATOR 1

Dec 10th, 2022
432
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.09 KB | None | 0 0
  1. // https://www.tradingview.com/script/MPZkvXfR-Chart-Champions-Part-1-nPOC-Levels-VWAPs/
  2. // Super Special Indicator OHLC CC
  3. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  4. // © Frien_dd
  5.  
  6. //@version=5
  7. indicator('Chart Champions - Part 1 - nPOC - Levels - VWAPs', shorttitle='CC - Pt1 - Lvls nPOC VWAPs', overlay=true)
  8.  
  9. NoLabel = input.bool(false, title='No Label Option ', tooltip='Option to have no Label Box')
  10. //Generic
  11. NoLabelOption = NoLabel ? label.style_none : label.style_label_left
  12. PriceLocation = NoLabel ? ' ' : ''
  13. PriceLocation1 = NoLabel ? ' ' : ''
  14. LabelSize = NoLabel ? size.normal : size.small
  15.  
  16.  
  17. ////////////////////////////////////////
  18. //Line Colors
  19. DanCCDailyInputColor = input.color(color.blue, title='Daily', group='User Selectable Line Colors', inline='Input 0')
  20. DanCCWeeklyInputColor = input.color(color.yellow, title='Weekly', group='User Selectable Line Colors', inline='Input 0')
  21. DanCCMonthlyInputColor = input.color(color.purple, title='Monthly', group='User Selectable Line Colors', inline='Input 0')
  22.  
  23.  
  24. //Daily Open
  25. DVWAPTxtLabelColor = NoLabel ? DanCCDailyInputColor : color.white
  26. WVWAPTxtLabelColor = NoLabel ? DanCCWeeklyInputColor : color.black
  27. MVWAPTxtLabelColor = NoLabel ? DanCCMonthlyInputColor : color.white
  28. A48VWAPTxtLabelColor = NoLabel ? color.navy : color.white
  29. A24VWAPTxtLabelColor = NoLabel ? color.blue : color.white
  30.  
  31.  
  32. /////////////////////////////////////////////////////////////////////
  33. /////////////////////////////////VWAPs
  34. show_DVWAPs = input.bool(false, title='Daily', group='Standard VWAPS - Daily, Weekly, Monthly', inline='VWAP1')
  35. show_WVWAPs = input.bool(false, title='Weekly', group='Standard VWAPS - Daily, Weekly, Monthly', inline='VWAP1')
  36. show_MVWAPs = input.bool(false, title='Monthly', group='Standard VWAPS - Daily, Weekly, Monthly', inline='VWAP1', tooltip='M-VWAP only shows on the 5 min and above timeframe / \'Live 24\' hour constantly updating VWAP')
  37.  
  38. show_pdDVWAPs = input.bool(false, title='Previous Day Close', group='Optional VWAPS', inline='VWAP1')
  39. show_Live24VWAPs = input.bool(false, title='Live 24', group='Optional VWAPS', inline='VWAP1')
  40. show_48VWAPs = input.bool(false, title='2D', group='Optional VWAPS', inline='VWAP1', tooltip='pdVWAP = Previous Day VWAP CLosing Price / \'Live 24\' hour constantly updating VWAP / Rolling 2 day VWAP')
  41.  
  42. show_pdDVWAPs_color = show_pdDVWAPs ? DanCCDailyInputColor : na
  43. show_pdDVWAPs_text = show_pdDVWAPs ? DVWAPTxtLabelColor : na
  44. show_DVWAPs_color = show_DVWAPs ? DanCCDailyInputColor : na
  45. show_DVWAPs_text = show_DVWAPs ? DVWAPTxtLabelColor : na
  46.  
  47. show_48VWAPs_color = show_48VWAPs ? color.navy : na
  48. show_48VWAPs_text = show_48VWAPs ? A48VWAPTxtLabelColor : na
  49.  
  50. show_Live24VWAPs_color = show_Live24VWAPs ? color.blue : na
  51. show_Live24VWAPs_text = show_Live24VWAPs ? A24VWAPTxtLabelColor : na
  52.  
  53. show_WVWAPs_color = show_WVWAPs ? DanCCWeeklyInputColor : na
  54. show_WVWAPs_text = show_WVWAPs ? WVWAPTxtLabelColor : na
  55. show_MVWAPs_color = show_MVWAPs ? DanCCMonthlyInputColor : na
  56. show_MVWAPs_text = show_MVWAPs ? MVWAPTxtLabelColor : na
  57.  
  58. is_today = year == year(timenow) and month == month(timenow) and dayofmonth == dayofmonth(timenow)
  59.  
  60.  
  61. ///VWAP rounding issue resolution
  62. f_round_up_to_tick(x, mintick) =>
  63. mult = 1 / mintick
  64. value = math.ceil(x * mult) / mult
  65. value
  66.  
  67. f_round_down_to_tick(x, mintick) =>
  68. mult = 1 / mintick
  69. value = math.floor(x * mult) / mult
  70. value
  71. /////////////////////////////////////////////////
  72.  
  73.  
  74. //Daily VWAP
  75. roundedVWAP = f_round_up_to_tick(ta.vwap, syminfo.mintick)
  76. VWAP = roundedVWAP
  77. //VWAP = round(vwap)
  78. plot(VWAP, 'D-VWAP', is_today ? show_DVWAPs_color : na, offset=0)
  79. var label VWAPLabel = na
  80. VWAPLabel := label.new(timenow, VWAP, xloc=xloc.bar_time, text=PriceLocation + 'D-VWAP - ' + str.tostring(VWAP), color=show_DVWAPs_color, textcolor=show_DVWAPs_text, style=NoLabelOption, size=LabelSize)
  81. label.delete(VWAPLabel[1])
  82.  
  83.  
  84. //Previous Day's Closing Vwap
  85. newday(res) =>
  86. t = time(res)
  87. ta.change(t) != 0 ? 1 : 0
  88. new_day = newday('D')
  89. pdVWAP = ta.valuewhen(new_day, VWAP[1], 0)
  90. plot(pdVWAP, 'pdVWAP', is_today ? show_pdDVWAPs_color : na, offset=0)
  91.  
  92. //plot(pdVWAP, "pdVWAP", change(pdVWAP) ? na : show_DVWAPs_color, offset = 0)
  93. var label pdVWAPLabel = na
  94. pdVWAPLabel := label.new(timenow, pdVWAP, xloc=xloc.bar_time, text=PriceLocation + 'pdVWAP - ' + str.tostring(pdVWAP), color=show_pdDVWAPs_color, textcolor=show_pdDVWAPs_text, style=NoLabelOption, size=LabelSize)
  95. label.delete(pdVWAPLabel[1])
  96.  
  97. //Weeekly VWAP
  98. src = hlc3
  99. wt = time('W')
  100.  
  101. wstart = na(wt[1]) or wt > wt[1]
  102.  
  103. wsumSrc = src * volume
  104. wsumVol = volume
  105. wsumSrc := wstart ? wsumSrc : wsumSrc + wsumSrc[1]
  106. wsumVol := wstart ? wsumVol : wsumVol + wsumVol[1]
  107.  
  108. WVWAP = wsumSrc / wsumVol
  109. wvw = f_round_up_to_tick(WVWAP, syminfo.mintick)
  110.  
  111. plot(timeframe.isintraday ? wvw : na, title='W-VWAP', color=show_WVWAPs_color)
  112. var label wVWAPLabel = na
  113. wVWAPLabel := label.new(timenow, timeframe.isintraday ? wvw : na, xloc=xloc.bar_time, text=PriceLocation + 'W-VWAP - ' + str.tostring(timeframe.isintraday ? wvw : na), color=show_WVWAPs_color, textcolor=show_WVWAPs_text, style=NoLabelOption, size=LabelSize)
  114. label.delete(wVWAPLabel[1])
  115.  
  116.  
  117. //Monthly VWAP
  118.  
  119.  
  120. var float vwapsum = na
  121. var float volumesum = na
  122.  
  123. newSession = ta.change(time('M'))
  124.  
  125. vwapsum := newSession ? hl2 * volume : hl2 * volume + vwapsum[1]
  126. volumesum := newSession ? volume : volume + volumesum[1]
  127.  
  128. MVWAP = vwapsum / volumesum
  129. mvw = f_round_up_to_tick(MVWAP, syminfo.mintick)
  130.  
  131. plot(newSession ? na : mvw, title='M-VWAP', color=show_MVWAPs_color, style=plot.style_linebr)
  132. var label mVWAPLabel = na
  133. mVWAPLabel := label.new(timenow, timeframe.isintraday ? mvw : na, xloc=xloc.bar_time, text=PriceLocation + 'M-VWAP - ' + str.tostring(timeframe.isintraday ? mvw : na), color=show_MVWAPs_color, textcolor=show_MVWAPs_text, style=NoLabelOption, size=LabelSize)
  134. label.delete(mVWAPLabel[1])
  135. /////////////////////////////////////////////////////////////////////
  136.  
  137.  
  138.  
  139. /////////////////////////2D VWAP
  140. source = hlc3
  141.  
  142. StartSun_session = na(time(timeframe.period, '0000-0000:7'))
  143. ShowMon_session = na(time(timeframe.period, '0000-0000:2'))
  144.  
  145. SMsumSrc = source * volume
  146. SMsumVol = volume
  147. SMsumSrc := StartSun_session and not StartSun_session[1] ? SMsumSrc : SMsumSrc + SMsumSrc[1]
  148. SMsumVol := StartSun_session and not StartSun_session[1] ? SMsumVol : SMsumVol + SMsumVol[1]
  149.  
  150. StartSun_condition = StartSun_session and not StartSun_session[1] ? na : StartSun_session and is_today ? SMsumSrc / SMsumVol : na
  151.  
  152. plot(StartSun_condition and not ShowMon_session ? StartSun_condition : na, title='Sun-2DVWAP', color=show_48VWAPs_color, linewidth=2, style=plot.style_linebr)
  153. StartSunLabel = label.new(timenow, StartSun_condition and not ShowMon_session ? StartSun_condition : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Sun-2DVWAP - ' + str.tostring(f_round_up_to_tick(StartSun_condition, syminfo.mintick)), color=show_48VWAPs_color, textcolor=show_48VWAPs_text, style=NoLabelOption, size=LabelSize)
  154. label.delete(StartSunLabel[1])
  155.  
  156.  
  157. //Monday Start 48 hour VWAP (Displays on Tuesday)
  158. StartMon_session = na(time(timeframe.period, '0000-0000:1'))
  159. ShowTues_session = na(time(timeframe.period, '0000-0000:3'))
  160.  
  161. MTsumSrc = source * volume
  162. MTsumVol = volume
  163. MTsumSrc := StartMon_session and not StartMon_session[1] ? MTsumSrc : MTsumSrc + MTsumSrc[1]
  164. MTsumVol := StartMon_session and not StartMon_session[1] ? MTsumVol : MTsumVol + MTsumVol[1]
  165.  
  166. StartMon_condition = StartMon_session and not StartMon_session[1] ? na : StartMon_session and is_today ? MTsumSrc / MTsumVol : na
  167.  
  168. plot(StartMon_condition and not ShowTues_session ? StartMon_condition : na, title='Mon-2DVWAP', color=show_48VWAPs_color, linewidth=2, style=plot.style_linebr)
  169. StartMonLabel = label.new(timenow, StartMon_condition and not ShowTues_session ? StartMon_condition : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Mon-2DVWAP - ' + str.tostring(f_round_up_to_tick(StartMon_condition, syminfo.mintick)), color=show_48VWAPs_color, textcolor=show_48VWAPs_text, style=NoLabelOption, size=LabelSize)
  170. label.delete(StartMonLabel[1])
  171.  
  172.  
  173. //Tuesday Start 48 hour VWAP (Displays on Wednesday)
  174. StartTues_session = na(time(timeframe.period, '0000-0000:2'))
  175. ShowWeds_session = na(time(timeframe.period, '0000-0000:4'))
  176.  
  177. TWsumSrc = source * volume
  178. TWsumVol = volume
  179. TWsumSrc := StartTues_session and not StartTues_session[1] ? TWsumSrc : TWsumSrc + TWsumSrc[1]
  180. TWsumVol := StartTues_session and not StartTues_session[1] ? TWsumVol : TWsumVol + TWsumVol[1]
  181.  
  182. StartTues_condition = StartTues_session and not StartTues_session[1] ? na : StartTues_session and is_today ? TWsumSrc / TWsumVol : na
  183.  
  184. plot(StartTues_condition and not ShowWeds_session ? StartTues_condition : na, title='Tues-2DVWAP', color=show_48VWAPs_color, linewidth=2, style=plot.style_linebr)
  185. StartTuesLabel = label.new(timenow, StartTues_condition and not ShowWeds_session ? StartTues_condition : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Tues-2DVWAP - ' + str.tostring(f_round_up_to_tick(StartTues_condition, syminfo.mintick)), color=show_48VWAPs_color, textcolor=show_48VWAPs_text, style=NoLabelOption, size=LabelSize)
  186. label.delete(StartTuesLabel[1])
  187.  
  188. //Wednesday Start 48 hour VWAP (Displays on Thursday)
  189. StartWeds_session = na(time(timeframe.period, '0000-0000:3'))
  190. ShowThurs_session = na(time(timeframe.period, '0000-0000:5'))
  191.  
  192. WTsumSrc = source * volume
  193. WTsumVol = volume
  194. WTsumSrc := StartWeds_session and not StartWeds_session[1] ? WTsumSrc : WTsumSrc + WTsumSrc[1]
  195. WTsumVol := StartWeds_session and not StartWeds_session[1] ? WTsumVol : WTsumVol + WTsumVol[1]
  196.  
  197. StartWeds_condition = StartWeds_session and not StartWeds_session[1] ? na : StartWeds_session and is_today ? WTsumSrc / WTsumVol : na
  198.  
  199. plot(StartWeds_condition and not ShowThurs_session ? StartWeds_condition : na, title='Weds-2DVWAP', color=show_48VWAPs_color, linewidth=2, style=plot.style_linebr)
  200. StartWedsLabel = label.new(timenow, StartWeds_condition and not ShowThurs_session ? StartWeds_condition : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Weds-2DVWAP - ' + str.tostring(f_round_up_to_tick(StartWeds_condition, syminfo.mintick)), color=show_48VWAPs_color, textcolor=show_48VWAPs_text, style=NoLabelOption, size=LabelSize)
  201. label.delete(StartWedsLabel[1])
  202.  
  203.  
  204. //Thursday Start 48 hour VWAP (Displays on Friday)
  205. StartThurs_session = na(time(timeframe.period, '0000-0000:4'))
  206. ShowFri_session = na(time(timeframe.period, '0000-0000:6'))
  207.  
  208. TFsumSrc = source * volume
  209. TFsumVol = volume
  210. TFsumSrc := StartThurs_session and not StartThurs_session[1] ? TFsumSrc : TFsumSrc + TFsumSrc[1]
  211. TFsumVol := StartThurs_session and not StartThurs_session[1] ? TFsumVol : TFsumVol + TFsumVol[1]
  212.  
  213. StartThurs_condition = StartThurs_session and not StartThurs_session[1] ? na : StartThurs_session and is_today ? TFsumSrc / TFsumVol : na
  214.  
  215. plot(StartThurs_condition and not ShowFri_session ? StartThurs_condition : na, title='Thurs-2DVWAP', color=show_48VWAPs_color, linewidth=2, style=plot.style_linebr)
  216. StartThursLabel = label.new(timenow, StartThurs_condition and not ShowFri_session ? StartThurs_condition : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Thurs-2DVWAP - ' + str.tostring(f_round_up_to_tick(StartThurs_condition, syminfo.mintick)), color=show_48VWAPs_color, textcolor=show_48VWAPs_text, style=NoLabelOption, size=LabelSize)
  217. label.delete(StartThursLabel[1])
  218.  
  219. //Friday Start 48 hour VWAP (Displays on Saturday)
  220. StartFri_session = na(time(timeframe.period, '0000-0000:5'))
  221. ShowSat_session = na(time(timeframe.period, '0000-0000:7'))
  222.  
  223. FSsumSrc = source * volume
  224. FSsumVol = volume
  225. FSsumSrc := StartFri_session and not StartFri_session[1] ? FSsumSrc : FSsumSrc + FSsumSrc[1]
  226. FSsumVol := StartFri_session and not StartFri_session[1] ? FSsumVol : FSsumVol + FSsumVol[1]
  227.  
  228. StartFri_condition = StartFri_session and not StartFri_session[1] ? na : StartFri_session and is_today ? FSsumSrc / FSsumVol : na
  229.  
  230. plot(StartFri_condition and not ShowSat_session ? StartFri_condition : na, title='Fri-2DVWAP', color=show_48VWAPs_color, linewidth=2, style=plot.style_linebr)
  231. StartFriLabel = label.new(timenow, StartFri_condition and not ShowSat_session ? StartFri_condition : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Fri-2DVWAP - ' + str.tostring(f_round_up_to_tick(StartFri_condition, syminfo.mintick)), color=show_48VWAPs_color, textcolor=show_48VWAPs_text, style=NoLabelOption, size=LabelSize)
  232. label.delete(StartFriLabel[1])
  233.  
  234.  
  235. //Saturday Start 48 hour VWAP (Displays on Sunday)
  236. StartSat_session = na(time(timeframe.period, '0000-0000:6'))
  237. ShowSun_session = na(time(timeframe.period, '0000-0000:1'))
  238.  
  239.  
  240. SSsumSrc = source * volume
  241. SSsumVol = volume
  242. SSsumSrc := StartSat_session and not StartSat_session[1] ? SSsumSrc : SSsumSrc + SSsumSrc[1]
  243. SSsumVol := StartSat_session and not StartSat_session[1] ? SSsumVol : SSsumVol + SSsumVol[1]
  244.  
  245. StartSat_condition = StartSat_session and not StartSat_session[1] ? na : StartSat_session and is_today ? SSsumSrc / SSsumVol : na
  246.  
  247. plot(StartSat_condition and not ShowSun_session ? StartSat_condition : na, title='Sat-2DVWAP', color=show_48VWAPs_color, linewidth=2, style=plot.style_linebr)
  248. StartSatLabel = label.new(timenow, StartSat_condition and not ShowSun_session ? StartSat_condition : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Sat-2DVWAP - ' + str.tostring(f_round_up_to_tick(StartSat_condition, syminfo.mintick)), color=show_48VWAPs_color, textcolor=show_48VWAPs_text, style=NoLabelOption, size=LabelSize)
  249. label.delete(StartSatLabel[1])
  250. /////////////48 Hour End
  251.  
  252.  
  253. ////////////////////////////////////////////////////////////////////////
  254. /////////24 HOUR ROLLING VWAP///////////////////////////////////////////
  255. ////////////////////////////////////////////////////////////////LabelSize
  256.  
  257. //VWAP 24 hour 1 min
  258. //TF = Time Frame
  259. TF_24_1 = timeframe.period == '1'
  260.  
  261. cumulativePeriod_24_1 = 1440
  262.  
  263. typicalPrice_24_1 = (high + low + close) / 3
  264. typicalPriceVolume_24_1 = typicalPrice_24_1 * volume
  265. cumulativeTypicalPriceVolume_24_1 = math.sum(typicalPriceVolume_24_1, cumulativePeriod_24_1)
  266. cumulativeVolume_24_1 = math.sum(volume, cumulativePeriod_24_1)
  267. vwapValue_24_1 = cumulativeTypicalPriceVolume_24_1 / cumulativeVolume_24_1
  268.  
  269. plot(vwapValue_24_1 and TF_24_1 ? vwapValue_24_1 : na, color=show_Live24VWAPs_color)
  270. var label vwapValueLabel_24_1 = na
  271. vwapValueLabel_24_1 := label.new(timenow, vwapValue_24_1 and TF_24_1 ? vwapValue_24_1 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_1, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  272. label.delete(vwapValueLabel_24_1[1])
  273.  
  274.  
  275. //VWAP 24 hour 2 min
  276. //TF = Time Frame
  277. TF_24_2 = timeframe.period == '2'
  278.  
  279. cumulativePeriod_24_2 = 720
  280.  
  281. typicalPrice_24_2 = (high + low + close) / 3
  282. typicalPriceVolume_24_2 = typicalPrice_24_2 * volume
  283. cumulativeTypicalPriceVolume_24_2 = math.sum(typicalPriceVolume_24_2, cumulativePeriod_24_2)
  284. cumulativeVolume_24_2 = math.sum(volume, cumulativePeriod_24_2)
  285. vwapValue_24_2 = cumulativeTypicalPriceVolume_24_2 / cumulativeVolume_24_2
  286.  
  287. plot(vwapValue_24_2 and TF_24_2 ? vwapValue_24_2 : na, color=show_Live24VWAPs_color)
  288. var label vwapValueLabel_24_2 = na
  289. vwapValueLabel_24_2 := label.new(timenow, vwapValue_24_2 and TF_24_2 ? vwapValue_24_2 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_2, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  290. label.delete(vwapValueLabel_24_2[1])
  291.  
  292.  
  293. //VWAP 24 hour 3 min
  294. //TF = Time Frame
  295. TF_24_3 = timeframe.period == '3'
  296.  
  297. cumulativePeriod_24_3 = 480
  298.  
  299. typicalPrice_24_3 = (high + low + close) / 3
  300. typicalPriceVolume_24_3 = typicalPrice_24_3 * volume
  301. cumulativeTypicalPriceVolume_24_3 = math.sum(typicalPriceVolume_24_3, cumulativePeriod_24_3)
  302. cumulativeVolume_24_3 = math.sum(volume, cumulativePeriod_24_3)
  303. vwapValue_24_3 = cumulativeTypicalPriceVolume_24_3 / cumulativeVolume_24_3
  304.  
  305. plot(vwapValue_24_3 and TF_24_3 ? vwapValue_24_3 : na, color=show_Live24VWAPs_color)
  306. var label vwapValueLabel_24_3 = na
  307. vwapValueLabel_24_3 := label.new(timenow, vwapValue_24_3 and TF_24_3 ? vwapValue_24_3 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_3, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  308. label.delete(vwapValueLabel_24_3[1])
  309.  
  310.  
  311. //VWAP 24 hour 4 min
  312. //TF = Time Frame
  313. TF_24_4 = timeframe.period == '4'
  314.  
  315. cumulativePeriod_24_4 = 360
  316.  
  317. typicalPrice_24_4 = (high + low + close) / 3
  318. typicalPriceVolume_24_4 = typicalPrice_24_4 * volume
  319. cumulativeTypicalPriceVolume_24_4 = math.sum(typicalPriceVolume_24_4, cumulativePeriod_24_4)
  320. cumulativeVolume_24_4 = math.sum(volume, cumulativePeriod_24_4)
  321. vwapValue_24_4 = cumulativeTypicalPriceVolume_24_4 / cumulativeVolume_24_4
  322.  
  323. plot(vwapValue_24_4 and TF_24_4 ? vwapValue_24_4 : na, color=show_Live24VWAPs_color)
  324. var label vwapValueLabel_24_4 = na
  325. vwapValueLabel_24_4 := label.new(timenow, vwapValue_24_4 and TF_24_4 ? vwapValue_24_4 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_4, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  326. label.delete(vwapValueLabel_24_4[1])
  327.  
  328. //VWAP 24 hour 5 min
  329. //TF = Time Frame
  330. TF_24_5 = timeframe.period == '5'
  331.  
  332. cumulativePeriod_24_5 = 288
  333.  
  334. typicalPrice_24_5 = (high + low + close) / 3
  335. typicalPriceVolume_24_5 = typicalPrice_24_5 * volume
  336. cumulativeTypicalPriceVolume_24_5 = math.sum(typicalPriceVolume_24_5, cumulativePeriod_24_5)
  337. cumulativeVolume_24_5 = math.sum(volume, cumulativePeriod_24_5)
  338. vwapValue_24_5 = cumulativeTypicalPriceVolume_24_5 / cumulativeVolume_24_5
  339.  
  340. plot(vwapValue_24_5 and TF_24_5 ? vwapValue_24_5 : na, color=show_Live24VWAPs_color)
  341. var label vwapValueLabel_24_5 = na
  342. vwapValueLabel_24_5 := label.new(timenow, vwapValue_24_5 and TF_24_5 ? vwapValue_24_5 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_5, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  343. label.delete(vwapValueLabel_24_5[1])
  344.  
  345.  
  346. //VWAP 24 hour 6 min
  347. //TF = Time Frame
  348. TF_24_6 = timeframe.period == '6'
  349.  
  350. cumulativePeriod_24_6 = 240
  351.  
  352. typicalPrice_24_6 = (high + low + close) / 3
  353. typicalPriceVolume_24_6 = typicalPrice_24_6 * volume
  354. cumulativeTypicalPriceVolume_24_6 = math.sum(typicalPriceVolume_24_6, cumulativePeriod_24_6)
  355. cumulativeVolume_24_6 = math.sum(volume, cumulativePeriod_24_6)
  356. vwapValue_24_6 = cumulativeTypicalPriceVolume_24_6 / cumulativeVolume_24_6
  357.  
  358. plot(vwapValue_24_6 and TF_24_6 ? vwapValue_24_6 : na, color=show_Live24VWAPs_color)
  359. var label vwapValueLabel_24_6 = na
  360. vwapValueLabel_24_6 := label.new(timenow, vwapValue_24_6 and TF_24_6 ? vwapValue_24_6 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_6, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  361. label.delete(vwapValueLabel_24_6[1])
  362.  
  363. //VWAP 24 hour 8 min
  364. //TF = Time Frame
  365. TF_24_8 = timeframe.period == '8'
  366.  
  367. cumulativePeriod_24_8 = 180
  368.  
  369. typicalPrice_24_8 = (high + low + close) / 3
  370. typicalPriceVolume_24_8 = typicalPrice_24_8 * volume
  371. cumulativeTypicalPriceVolume_24_8 = math.sum(typicalPriceVolume_24_8, cumulativePeriod_24_8)
  372. cumulativeVolume_24_8 = math.sum(volume, cumulativePeriod_24_8)
  373. vwapValue_24_8 = cumulativeTypicalPriceVolume_24_8 / cumulativeVolume_24_8
  374.  
  375. plot(vwapValue_24_8 and TF_24_8 ? vwapValue_24_8 : na, color=show_Live24VWAPs_color)
  376. var label vwapValueLabel_24_8 = na
  377. vwapValueLabel_24_8 := label.new(timenow, vwapValue_24_8 and TF_24_8 ? vwapValue_24_8 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_8, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  378. label.delete(vwapValueLabel_24_8[1])
  379.  
  380.  
  381. //VWAP 24 hour 9 min
  382. //TF = Time Frame
  383. TF_24_9 = timeframe.period == '9'
  384.  
  385. cumulativePeriod_24_9 = 160
  386.  
  387. typicalPrice_24_9 = (high + low + close) / 3
  388. typicalPriceVolume_24_9 = typicalPrice_24_9 * volume
  389. cumulativeTypicalPriceVolume_24_9 = math.sum(typicalPriceVolume_24_9, cumulativePeriod_24_9)
  390. cumulativeVolume_24_9 = math.sum(volume, cumulativePeriod_24_9)
  391. vwapValue_24_9 = cumulativeTypicalPriceVolume_24_9 / cumulativeVolume_24_9
  392.  
  393. plot(vwapValue_24_9 and TF_24_9 ? vwapValue_24_9 : na, color=show_Live24VWAPs_color)
  394. var label vwapValueLabel_24_9 = na
  395. vwapValueLabel_24_9 := label.new(timenow, vwapValue_24_9 and TF_24_9 ? vwapValue_24_9 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_9, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  396. label.delete(vwapValueLabel_24_9[1])
  397.  
  398.  
  399. //VWAP 24 hour 10 min
  400. //TF = Time Frame
  401. TF_24_10 = timeframe.period == '10'
  402.  
  403. cumulativePeriod_24_10 = 144
  404.  
  405. typicalPrice_24_10 = (high + low + close) / 3
  406. typicalPriceVolume_24_10 = typicalPrice_24_10 * volume
  407. cumulativeTypicalPriceVolume_24_10 = math.sum(typicalPriceVolume_24_10, cumulativePeriod_24_10)
  408. cumulativeVolume_24_10 = math.sum(volume, cumulativePeriod_24_10)
  409. vwapValue_24_10 = cumulativeTypicalPriceVolume_24_10 / cumulativeVolume_24_10
  410.  
  411. plot(vwapValue_24_10 and TF_24_10 ? vwapValue_24_10 : na, color=show_Live24VWAPs_color)
  412. var label vwapValueLabel_24_10 = na
  413. vwapValueLabel_24_10 := label.new(timenow, vwapValue_24_10 and TF_24_10 ? vwapValue_24_10 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_10, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  414. label.delete(vwapValueLabel_24_10[1])
  415.  
  416.  
  417. //VWAP 24 hour 12 min
  418. //TF = Time Frame
  419. TF_24_12 = timeframe.period == '12'
  420.  
  421. cumulativePeriod_24_12 = 120
  422.  
  423. typicalPrice_24_12 = (high + low + close) / 3
  424. typicalPriceVolume_24_12 = typicalPrice_24_12 * volume
  425. cumulativeTypicalPriceVolume_24_12 = math.sum(typicalPriceVolume_24_12, cumulativePeriod_24_12)
  426. cumulativeVolume_24_12 = math.sum(volume, cumulativePeriod_24_12)
  427. vwapValue_24_12 = cumulativeTypicalPriceVolume_24_12 / cumulativeVolume_24_12
  428.  
  429. plot(vwapValue_24_12 and TF_24_12 ? vwapValue_24_12 : na, color=show_Live24VWAPs_color)
  430. var label vwapValueLabel_24_12 = na
  431. vwapValueLabel_24_12 := label.new(timenow, vwapValue_24_12 and TF_24_12 ? vwapValue_24_12 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_12, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  432. label.delete(vwapValueLabel_24_12[1])
  433.  
  434.  
  435.  
  436. //VWAP 24 hour 15 min
  437. //TF = Time Frame
  438. TF_24_15 = timeframe.period == '15'
  439.  
  440. cumulativePeriod_24_15 = 96
  441.  
  442. typicalPrice_24_15 = (high + low + close) / 3
  443. typicalPriceVolume_24_15 = typicalPrice_24_15 * volume
  444. cumulativeTypicalPriceVolume_24_15 = math.sum(typicalPriceVolume_24_15, cumulativePeriod_24_15)
  445. cumulativeVolume_24_15 = math.sum(volume, cumulativePeriod_24_15)
  446. vwapValue_24_15 = cumulativeTypicalPriceVolume_24_15 / cumulativeVolume_24_15
  447.  
  448. plot(vwapValue_24_15 and TF_24_15 ? vwapValue_24_15 : na, color=show_Live24VWAPs_color)
  449. var label vwapValueLabel_24_15 = na
  450. vwapValueLabel_24_15 := label.new(timenow, vwapValue_24_15 and TF_24_15 ? vwapValue_24_15 : na, xloc=xloc.bar_time, text=PriceLocation1 + 'Live 24 VWAP - ' + str.tostring(f_round_up_to_tick(vwapValue_24_15, syminfo.mintick)), color=show_Live24VWAPs_color, textcolor=show_Live24VWAPs_text, style=NoLabelOption, size=LabelSize)
  451. label.delete(vwapValueLabel_24_15[1])
  452.  
  453.  
  454.  
  455.  
  456.  
  457. ///////////////////////////////
  458.  
  459. //Monthly Open
  460. mOpen = request.security(syminfo.tickerid, 'M', open, lookahead=barmerge.lookahead_on)
  461. pmOpen = request.security(syminfo.tickerid, 'M', open[1], lookahead=barmerge.lookahead_on)
  462.  
  463. pmHigh = request.security(syminfo.tickerid, 'M', high[1], lookahead=barmerge.lookahead_on)
  464. pmLow = request.security(syminfo.tickerid, 'M', low[1], lookahead=barmerge.lookahead_on)
  465.  
  466.  
  467. //Weekly Open
  468. wOpen = request.security(syminfo.tickerid, 'W', open, lookahead=barmerge.lookahead_on)
  469. pwOpen = request.security(syminfo.tickerid, 'W', open[1], lookahead=barmerge.lookahead_on)
  470.  
  471.  
  472. //Previous Day Open High Low
  473. dOpen = request.security(syminfo.tickerid, 'D', open, lookahead=barmerge.lookahead_on)
  474. pdOpen = request.security(syminfo.tickerid, 'D', open[1], lookahead=barmerge.lookahead_on)
  475. dbyOpen = request.security(syminfo.tickerid, 'D', open[2], lookahead=barmerge.lookahead_on)
  476.  
  477. pdHigh = request.security(syminfo.tickerid, 'D', high[1], lookahead=barmerge.lookahead_on)
  478. pdLow = request.security(syminfo.tickerid, 'D', low[1], lookahead=barmerge.lookahead_on)
  479. pdEQ = (pdHigh + pdLow) / 2
  480.  
  481. pwHigh = request.security(syminfo.tickerid, 'W', high[1], lookahead=barmerge.lookahead_on)
  482. pwLow = request.security(syminfo.tickerid, 'W', low[1], lookahead=barmerge.lookahead_on)
  483. pwEQ = (pwHigh + pwLow) / 2
  484.  
  485. //Current Day High Low
  486. var Yesterday = 0
  487. var DailyHigh = 0.0
  488. var DailyLow = 0.0
  489.  
  490. Today = time('D')
  491. CheckDay = Today != Yesterday
  492. Yesterday := Today
  493. DailyHigh := CheckDay or high > DailyHigh ? high[0] : DailyHigh
  494. DailyLow := CheckDay or low < DailyLow ? low[0] : DailyLow
  495.  
  496.  
  497.  
  498. /// Input to show Lines and Labels for right of price in reference to the above
  499. ExtendAxisLine = input.bool(false, title='Extend Axis value lines across chart', group='Daily, Weekly, Monthly, EQ Price Axis', tooltip='-d = Daily, w = Weekly, m = Monthly, p = Previous, dby = Day Before Yesterday')
  500.  
  501. ExtendOption = ExtendAxisLine ? extend.both : extend.right
  502.  
  503. PriceDaily = input.bool(true, title='- pdHigh - pdLow - pdEQ', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Daily 1')
  504. showdOpen = input.bool(false, title='- dOpen', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Daily')
  505. showdLow = input.bool(false, title='- dLow', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Daily')
  506. showdHigh = input.bool(false, title='- dHigh', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Daily')
  507. showpdOpen = input.bool(false, title='- pdOpen', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Daily')
  508. showdbyOpen = input.bool(false, title='- dbyOpen', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Daily')
  509.  
  510. PriceWeekly = input.bool(true, title='- pwEQ', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Weekly')
  511. showwOpen = input.bool(false, title='- wOpen', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Weekly')
  512. showpwOpen = input.bool(false, title='- pwOpen', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Weekly')
  513. showpwHigh = input.bool(false, title='- pwHigh', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Weekly')
  514. showpwLow = input.bool(false, title='- pwLow', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Weekly')
  515.  
  516. showpmOpen = input.bool(false, title='- mOpen', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Monthly')
  517. showmOpen = input.bool(false, title='- pmOpen', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Monthly')
  518. showpmHigh = input.bool(false, title='- pmHigh', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Monthly')
  519. showpmLow = input.bool(false, title='- pmLow', group='Daily, Weekly, Monthly, EQ Price Axis', inline='Monthly')
  520.  
  521.  
  522. // Line Var
  523. var line pmHighLine = na
  524. var line pmLowLine = na
  525. var line mOpenLine = na
  526. var line pmOpenLine = na
  527. var line pwHighLine = na
  528. var line pwLowLine = na
  529. var line wOpenLine = na
  530. var line pwOpenLine = na
  531. var line pdOpenLine = na
  532. var line dOpenLine = na
  533. var line dbyOpenLine = na
  534. var line pdHighLine = na
  535. var line pdLowLine = na
  536. var line pdEQLine = na
  537. var line pwEQLine = na
  538. var line dLowLine = na
  539. var line dHighLine = na
  540.  
  541.  
  542.  
  543. //Label Var
  544. var label pmHighLabel = na
  545. var label pmLowLabel = na
  546. var label mOpenLabel = na
  547. var label pmOpenLabel = na
  548. var label pwHighLabel = na
  549. var label pwLowLabel = na
  550. var label wOpenLabel = na
  551. var label pwOpenLabel = na
  552. var label dOpenLabel = na
  553. var label pdOpenLabel = na
  554. var label dbyOpenLabel = na
  555. var label pdHighLabel = na
  556. var label pdLowLabel = na
  557. var label pdEQLabel = na
  558. var label pwEQLabel = na
  559. var label dLowLabel = na
  560. var label dHighLabel = na
  561.  
  562.  
  563. //Create Line
  564. if PriceDaily
  565.  
  566. pdHighLine := line.new(bar_index[1], pdHigh, bar_index, pdHigh, color=DanCCDailyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  567. pdLowLine := line.new(bar_index[1], pdLow, bar_index, pdLow, color=DanCCDailyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  568. pdEQLine := line.new(bar_index[1], pdEQ, bar_index, pdEQ, color=DanCCDailyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  569.  
  570. //Create Label
  571. pdHighLabel := label.new(bar_index, pdHigh, text=' pdHigh - ' + str.tostring(pdHigh), color=DanCCDailyInputColor, textcolor=DanCCDailyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  572. pdLowLabel := label.new(bar_index, pdLow, text=' pdLow - ' + str.tostring(pdLow), color=DanCCDailyInputColor, textcolor=DanCCDailyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  573. pdEQLabel := label.new(bar_index, pdEQ, text=' pdEQ - ' + str.tostring(pdEQ), color=DanCCDailyInputColor, textcolor=DanCCDailyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  574.  
  575. //Delete Line
  576. line.delete(pdHighLine[1])
  577. line.delete(pdLowLine[1])
  578. line.delete(pdEQLine[1])
  579.  
  580. //Delete Label
  581. label.delete(pdHighLabel[1])
  582. label.delete(pdLowLabel[1])
  583. label.delete(pdEQLabel[1])
  584.  
  585.  
  586. /////////////////////Weekly
  587. if PriceWeekly
  588. pwEQLine := line.new(bar_index[1], pwEQ, bar_index, pwEQ, color=DanCCWeeklyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  589. //Create Label
  590. pwEQLabel := label.new(bar_index, pwEQ, text=' pwEQ - ' + str.tostring(pwEQ), color=DanCCWeeklyInputColor, textcolor=DanCCWeeklyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  591. //Delete Line
  592. line.delete(pwEQLine[1])
  593. //Delete Label
  594. label.delete(pwEQLabel[1])
  595.  
  596. //Create Line
  597. if showpwHigh
  598. pwHighLine := line.new(bar_index[1], pwHigh, bar_index, pwHigh, color=DanCCWeeklyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  599. //Delete Line
  600. line.delete(pwHighLine[1])
  601. //Create Label
  602. pwHighLabel := label.new(bar_index, pwHigh, text=' pwHigh - ' + str.tostring(pwHigh), color=DanCCWeeklyInputColor, textcolor=DanCCWeeklyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  603. //Delete Label
  604. label.delete(pwHighLabel[1])
  605.  
  606.  
  607. //Create Line
  608. if showpwLow
  609. pwLowLine := line.new(bar_index[1], pwLow, bar_index, pwLow, color=DanCCWeeklyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  610. //Delete Line
  611. line.delete(pwLowLine[1])
  612. //Create Label
  613. pwLowLabel := label.new(bar_index, pwLow, text=' pwLow - ' + str.tostring(pwLow), color=DanCCWeeklyInputColor, textcolor=DanCCWeeklyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  614. //Delete Label
  615. label.delete(pwLowLabel[1])
  616.  
  617.  
  618.  
  619.  
  620. ////////////////////Monthly
  621. if showmOpen
  622. mOpenLine := line.new(bar_index[1], mOpen, bar_index, mOpen, color=DanCCMonthlyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  623. //Create Label
  624. mOpenLabel := label.new(bar_index, mOpen, text=' mOpen - ' + str.tostring(mOpen), color=DanCCMonthlyInputColor, textcolor=DanCCMonthlyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  625. //Delete Line
  626. line.delete(mOpenLine[1])
  627. //Delete Label
  628. label.delete(mOpenLabel[1])
  629.  
  630. if showpmOpen
  631. pmOpenLine := line.new(bar_index[1], pmOpen, bar_index, pmOpen, color=DanCCMonthlyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  632. //Create Label
  633. pmOpenLabel := label.new(bar_index, pmOpen, text=' pmOpen - ' + str.tostring(pmOpen), color=DanCCMonthlyInputColor, textcolor=DanCCMonthlyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  634. //Delete Line
  635. line.delete(pmOpenLine[1])
  636. //Delete Label
  637. label.delete(pmOpenLabel[1])
  638.  
  639. //Create Line
  640. if showpmHigh
  641. pmHighLine := line.new(bar_index[1], pmHigh, bar_index, pmHigh, color=DanCCMonthlyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  642. //Delete Line
  643. line.delete(pmHighLine[1])
  644. //Create Label
  645. pmHighLabel := label.new(bar_index, pmHigh, text=' pmHigh - ' + str.tostring(pmHigh), color=DanCCMonthlyInputColor, textcolor=DanCCMonthlyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  646. //Delete Label
  647. label.delete(pmHighLabel[1])
  648.  
  649.  
  650.  
  651. //Create Line
  652. if showpmLow
  653. pmLowLine := line.new(bar_index[1], pmLow, bar_index, pmLow, color=DanCCMonthlyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  654. //Delete Line
  655. line.delete(pmLowLine[1])
  656. //Create Label
  657. pmLowLabel := label.new(bar_index, pmLow, text=' pmLow - ' + str.tostring(pmLow), color=DanCCMonthlyInputColor, textcolor=DanCCMonthlyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  658. //Delete Label
  659. label.delete(pmLowLabel[1])
  660.  
  661.  
  662.  
  663. /////////Optional Levels
  664.  
  665. if showdOpen
  666. dOpenLine := line.new(bar_index[1], dOpen, bar_index, dOpen, color=DanCCDailyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  667. dOpenLabel := label.new(bar_index, dOpen, text=' dOpen - ' + str.tostring(dOpen), color=DanCCDailyInputColor, textcolor=DanCCDailyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  668. line.delete(dOpenLine[1])
  669. label.delete(dOpenLabel[1])
  670.  
  671.  
  672.  
  673. if showdbyOpen
  674. dbyOpenLine := line.new(bar_index[1], dbyOpen, bar_index, dbyOpen, color=DanCCDailyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  675. dbyOpenLabel := label.new(bar_index, dbyOpen, text=' dbyOpen - ' + str.tostring(dbyOpen), color=DanCCDailyInputColor, textcolor=color.blue, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  676. line.delete(dbyOpenLine[1])
  677. label.delete(dbyOpenLabel[1])
  678.  
  679. if showpdOpen
  680. pdOpenLine := line.new(bar_index[1], pdOpen, bar_index, pdOpen, color=DanCCDailyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  681. pdOpenLabel := label.new(bar_index, pdOpen, text=' pdOpen - ' + str.tostring(pdOpen), color=DanCCDailyInputColor, textcolor=DanCCDailyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  682. line.delete(pdOpenLine[1])
  683. label.delete(pdOpenLabel[1])
  684.  
  685. if showwOpen
  686. wOpenLine := line.new(bar_index[1], wOpen, bar_index, wOpen, color=DanCCWeeklyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  687. wOpenLabel := label.new(bar_index, wOpen, text=' wOpen - ' + str.tostring(wOpen), color=DanCCWeeklyInputColor, textcolor=DanCCWeeklyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  688. line.delete(wOpenLine[1])
  689. label.delete(wOpenLabel[1])
  690.  
  691. if showpwOpen
  692. pwOpenLine := line.new(bar_index[1], pwOpen, bar_index, pwOpen, color=DanCCWeeklyInputColor, style=line.style_dashed, width=1, extend=ExtendOption)
  693. pwOpenLabel := label.new(bar_index, pwOpen, text=' pwOpen - ' + str.tostring(pwOpen), color=DanCCWeeklyInputColor, textcolor=DanCCWeeklyInputColor, style=label.style_none, size=size.normal, xloc=xloc.bar_index)
  694. line.delete(pwOpenLine[1])
  695. label.delete(pwOpenLabel[1])
  696.  
  697.  
  698. if showdLow
  699. dLowLine := line.new(bar_index[1], DailyLow, bar_index, DailyLow, color=color.white, style=line.style_solid, width=1, extend=ExtendOption)
  700. dLowLabel := label.new(bar_index, DailyLow, text=' dLow - ' + str.tostring(DailyLow), color=color.white, textcolor=color.white, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  701. line.delete(dLowLine[1])
  702. label.delete(dLowLabel[1])
  703.  
  704. if showdHigh
  705. dHighLine := line.new(bar_index[1], DailyHigh, bar_index, DailyHigh, color=color.white, style=line.style_solid, width=1, extend=ExtendOption)
  706. dHighLabel := label.new(bar_index, DailyHigh, text=' dHigh - ' + str.tostring(DailyHigh), color=color.white, textcolor=color.white, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  707. line.delete(dHighLine[1])
  708. label.delete(dHighLabel[1])
  709.  
  710.  
  711.  
  712.  
  713. //Daily
  714.  
  715. show_DanCCInput1 = input.bool(false, title='', group='Manual Daily Inputs', inline='Input 1')
  716. DanCCInput1_color = show_DanCCInput1 ? DanCCDailyInputColor : na
  717. DanCCInput1 = input.int(59000, title='1', group='Manual Daily Inputs', inline='Input 1')
  718. plot(show_DanCCInput1 ? DanCCInput1 : na, 'Daily 1', ta.change(DanCCInput1) ? na : DanCCInput1_color, offset=0)
  719. if show_DanCCInput1
  720. DanCC1 = label.new(bar_index[25], DanCCInput1, text='Daily 1 - ' + str.tostring(DanCCInput1), color=DanCCInput1_color, textcolor=DanCCInput1_color, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  721. label.delete(DanCC1[1])
  722.  
  723. show_DanCCInput2 = input.bool(false, title='', group='Manual Daily Inputs', inline='Input 1')
  724. DanCCInput2_color = show_DanCCInput2 ? DanCCDailyInputColor : na
  725. DanCCInput2 = input.int(59300, title='2', group='Manual Daily Inputs', inline='Input 1')
  726. plot(show_DanCCInput2 ? DanCCInput2 : na, 'Daily 2', ta.change(DanCCInput2) ? na : DanCCInput2_color, offset=0)
  727. if show_DanCCInput2
  728. DanCC2 = label.new(bar_index[25], DanCCInput2, text='Daily 2 - ' + str.tostring(DanCCInput2), color=DanCCInput2_color, textcolor=DanCCInput2_color, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  729. label.delete(DanCC2[1])
  730.  
  731.  
  732.  
  733. show_DanCCInput3 = input.bool(false, title='', group='Manual Daily Inputs', inline='Input 1')
  734. DanCCInput3_color = show_DanCCInput3 ? DanCCDailyInputColor : na
  735. DanCCInput3 = input.int(59250, title='3', group='Manual Daily Inputs', inline='Input 1', tooltip='Levels can be configured to alerts')
  736. plot(show_DanCCInput3 ? DanCCInput3 : na, 'Daily 3', ta.change(DanCCInput3) ? na : DanCCInput3_color, offset=0)
  737. if show_DanCCInput3
  738. DanCC3 = label.new(bar_index[25], DanCCInput3, text='Daily 3 - ' + str.tostring(DanCCInput3), color=DanCCInput3_color, textcolor=DanCCInput3_color, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  739. label.delete(DanCC3[1])
  740.  
  741.  
  742.  
  743.  
  744. // //Weekly
  745.  
  746. show_DanCCInput1W = input.bool(false, title='', group='Manual Weekly Inputs', inline='Input 2')
  747. DanCCInput1_colorW = show_DanCCInput1W ? DanCCWeeklyInputColor : na
  748. DanCCInput1W = input.int(58200, title='1', group='Manual Weekly Inputs', inline='Input 2')
  749. plot(show_DanCCInput1W ? DanCCInput1W : na, 'Weekly 1', ta.change(DanCCInput1W) ? na : DanCCInput1_colorW, offset=0)
  750. if show_DanCCInput1W
  751. DanCC1W = label.new(bar_index[25], DanCCInput1W, text='Weekly 1 - ' + str.tostring(DanCCInput1W), color=DanCCInput1_colorW, textcolor=DanCCInput1_colorW, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  752. label.delete(DanCC1W[1])
  753.  
  754.  
  755.  
  756.  
  757. show_DanCCInput2W = input.bool(false, title='', group='Manual Weekly Inputs', inline='Input 2')
  758. DanCCInput2_colorW = show_DanCCInput2W ? DanCCWeeklyInputColor : na
  759. DanCCInput2W = input.int(58300, title='2', group='Manual Weekly Inputs', inline='Input 2')
  760. plot(show_DanCCInput2W ? DanCCInput2W : na, 'Weekly 2', ta.change(DanCCInput2W) ? na : DanCCInput2_colorW, offset=0)
  761. if show_DanCCInput2W
  762. DanCC2W = label.new(bar_index[25], DanCCInput2W, text='Weekly 2 - ' + str.tostring(DanCCInput2W), color=DanCCInput2_colorW, textcolor=DanCCInput2_colorW, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  763. label.delete(DanCC2W[1])
  764.  
  765.  
  766.  
  767.  
  768. show_DanCCInput3W = input.bool(false, title='', group='Manual Weekly Inputs', inline='Input 2')
  769. DanCCInput3_colorW = show_DanCCInput3W ? DanCCWeeklyInputColor : na
  770. DanCCInput3W = input.int(60250, title='3', group='Manual Weekly Inputs', inline='Input 2', tooltip='Levels can be configured to alerts')
  771. plot(show_DanCCInput3W ? DanCCInput3W : na, 'Weekly 3', ta.change(DanCCInput3W) ? na : DanCCInput3_colorW, offset=0)
  772. if show_DanCCInput3W
  773. DanCC3W = label.new(bar_index[25], DanCCInput3W, text='Weekly 3 - ' + str.tostring(DanCCInput3W), color=DanCCInput3_colorW, textcolor=DanCCInput3_colorW, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  774. label.delete(DanCC3W[1])
  775.  
  776.  
  777.  
  778.  
  779. // /////Monthly
  780. show_DanCCInput1M = input.bool(false, title='', group='Manual Monthly Inputs', inline='Input 3')
  781. DanCCInput1_colorM = show_DanCCInput1M ? DanCCMonthlyInputColor : na
  782. DanCCInput1M = input.int(61200, title='1', group='Manual Monthly Inputs', inline='Input 3')
  783. plot(show_DanCCInput1M ? DanCCInput1M : na, 'Monthly 1', ta.change(DanCCInput1M) ? na : DanCCInput1_colorM, offset=0)
  784. if show_DanCCInput1M
  785. DanCC1M = label.new(bar_index[25], DanCCInput1M, text='Monthly 1 - ' + str.tostring(DanCCInput1M), color=DanCCInput1_colorM, textcolor=DanCCInput1_colorM, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  786. label.delete(DanCC1M[1])
  787.  
  788.  
  789.  
  790.  
  791. show_DanCCInput2M = input.bool(false, title='', group='Manual Monthly Inputs', inline='Input 3')
  792. DanCCInput2_colorM = show_DanCCInput2M ? DanCCMonthlyInputColor : na
  793. DanCCInput2M = input.int(59900, title='2', group='Manual Monthly Inputs', inline='Input 3')
  794. plot(show_DanCCInput2M ? DanCCInput2M : na, 'Monthly 2', ta.change(DanCCInput2M) ? na : DanCCInput2_colorM, offset=0)
  795. if show_DanCCInput2M
  796. DanCC2M = label.new(bar_index[25], DanCCInput2M, text='Monthly 2 - ' + str.tostring(DanCCInput2M), color=DanCCInput2_colorM, textcolor=DanCCInput2_colorM, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  797. label.delete(DanCC2M[1])
  798.  
  799.  
  800. show_DanCCInput3M = input.bool(false, title='', group='Manual Monthly Inputs', inline='Input 3')
  801. DanCCInput3_colorM = show_DanCCInput3M ? DanCCMonthlyInputColor : na
  802. DanCCInput3M = input.int(60350, title='3', group='Manual Monthly Inputs', inline='Input 3', tooltip='Levels can be configured to alerts')
  803. plot(show_DanCCInput3M ? DanCCInput3M : na, 'Monthly 3', ta.change(DanCCInput3M) ? na : DanCCInput3_colorM, offset=0)
  804. if show_DanCCInput3M
  805. DanCC3M = label.new(bar_index[25], DanCCInput3M, text='Monthly 3 - ' + str.tostring(DanCCInput3M), color=DanCCInput3_colorM, textcolor=DanCCInput3_colorM, style=label.style_none, size=size.normal, xloc=xloc.bar_index, textalign=text.align_right)
  806. label.delete(DanCC3M[1])
  807.  
  808.  
  809. ////////////////////////////////////////Input Daniel Targets - Finish
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816. //Session Rules
  817. bartimeSess = time('D')
  818. newbarSess = bartimeSess != bartimeSess[1]
  819.  
  820. show_nPOCs = input.bool(true, title='Show Naked POCs', group='Naked Point of Control Settings')
  821. dtf = input.timeframe('D', title='nPOC - Time Frame', group='Naked Point of Control Settings')
  822. resolution = input.float(1, title='Resolution (Change resolution to Symbol decimal)', group='Symbol Settings', tooltip='E.g. BTCUSD = 1, XRPUSD = 0.00001, QTUMUSD = 0.001 ')
  823.  
  824. show_nPOCs_color = show_nPOCs ? #FFC0CB : na
  825.  
  826. is_new_bar(t) =>
  827. ta.change(time(t)) != 0
  828. round_to_nearest(v, x) =>
  829. math.round(v / x) * x
  830.  
  831. tick_size = math.max(syminfo.mintick, resolution)
  832.  
  833. var a = array.new_float(0)
  834.  
  835. a_min = 0.0
  836. a_min := nz(a_min[1], round_to_nearest(low, tick_size))
  837. a_max = 0.0
  838. a_max := nz(a_max[1], round_to_nearest(high, tick_size))
  839.  
  840. d_switch = is_new_bar(dtf)
  841.  
  842. if d_switch
  843. a_min := low
  844. a_max := high
  845. array.clear(a)
  846.  
  847. // Scaled min max
  848. v_min = int(round_to_nearest(low - a_min, tick_size) / tick_size)
  849. v_max = int(round_to_nearest(high - a_min, tick_size) / tick_size)
  850.  
  851. // Scaled candle range
  852. ticks = v_max - v_min
  853.  
  854. vol = volume / (ticks == 0 ? 1 : ticks)
  855.  
  856. for i = v_min to math.max(v_max - 1, v_min) by 1
  857. // Insert new low value
  858. if i < 0
  859. array.insert(a, i - v_min, vol)
  860. continue
  861.  
  862. // Adjust index
  863. offset = v_min < 0 ? math.abs(v_min) : 0
  864. index = int(i + offset)
  865.  
  866. // Push new high value
  867. if index >= array.size(a)
  868. array.push(a, vol)
  869. continue
  870.  
  871. // Update existing value
  872. v = array.get(a, index)
  873. array.set(a, index, v + vol)
  874.  
  875. // Array bounds
  876. a_min := math.min(a_min, round_to_nearest(low, tick_size))
  877. a_max := math.max(a_max, round_to_nearest(high, tick_size))
  878. a_size = array.size(a)
  879.  
  880. // POC
  881.  
  882. poc_index = -1
  883. poc_prev = -1.0
  884. sum_vol = 0.0
  885.  
  886. for i = 0 to a_size - 1 by 1
  887. poc_current = array.get(a, i)
  888. sum_vol += poc_current
  889.  
  890. if poc_current > poc_prev
  891. poc_prev := poc_current
  892. poc_index := i
  893. poc_index
  894.  
  895.  
  896. float p_poc = 0.0
  897. float d_poc = 0.0
  898. float b_poc = 0.0
  899.  
  900. d_poc := poc_index * tick_size + a_min
  901. p_poc := is_new_bar(dtf) ? d_poc[1] : p_poc[1]
  902.  
  903. var line[] uplines = array.new_line()
  904. var float[] uppocs = array.new_float()
  905.  
  906. if is_new_bar(dtf)
  907. array.push(uplines, line.new(time, p_poc, time + 1, p_poc, xloc=xloc.bar_time, color=show_nPOCs_color, extend=extend.right))
  908. array.push(uppocs, p_poc)
  909.  
  910. if array.size(uppocs) > 0
  911. for i = 0 to array.size(uppocs) - 1 by 1
  912. myuppoc = array.get(uppocs, i)
  913. if myuppoc > low
  914. line.delete(array.get(uplines, i))
  915.  
  916. var line[] downlines = array.new_line()
  917. var float[] downpocs = array.new_float()
  918.  
  919. if is_new_bar(dtf)
  920. array.push(downlines, line.new(time, p_poc, time + 1, p_poc, xloc=xloc.bar_time, color=show_nPOCs_color, extend=extend.right))
  921. array.push(downpocs, p_poc)
  922.  
  923. if array.size(downpocs) > 0
  924. for i = 0 to array.size(downpocs) - 1 by 1
  925. mydownpoc = array.get(downpocs, i)
  926. if mydownpoc < high
  927. line.delete(array.get(downlines, i))
  928.  
  929.  
  930.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement