// draw hist if barstate.islast and showHist // Define lows and highs of the histograms for i = 0 to numOfHistograms - 1 histogramLow = rangeLow + histogramHeight * i histogramHigh = rangeLow + histogramHeight * (i + 1) array.set(histogramLowList, i, histogramLow) array.set(histogramHighList, i, histogramHigh)
for i = 0 to array.size(histogramData) - 1 y = array.get(histogramData, i)
for j = 0 to numOfHistograms - 1 histogramLow = array.get(histogramLowList, j) histogramHigh = array.get(histogramHighList, j) if y >= histogramLow and y <= histogramHigh array.set(histogramtargetList, j, array.get(histogramtargetList, j) + 1)
for i = 0 to numOfHistograms - 1 histogramLow = array.get(histogramLowList, i) histogramHigh = array.get(histogramHighList, i) histogramtarget = array.get(histogramtargetList, i) histogramWidth = math.floor((histogramtarget + 0.49) * 2)
if barstate.islast and not showLine for i=0 to array.size(h3Array) - 1 line.delete(array.get(h3Array, i))
for i=0 to array.size(h2Array) - 1 line.delete(array.get(h2Array, i))
for i=0 to array.size(h1Array) - 1 line.delete(array.get(h1Array, i))
else if barstate.islast and showLocalOnly for i=0 to array.size(h3Array) - 1 if line.get_y1(array.get(h3Array, i)) < rangeLow or line.get_y1(array.get(h3Array, i)) > rangeHigh line.delete(array.get(h3Array, i))
for i=0 to array.size(h2Array) - 1 if line.get_y1(array.get(h2Array, i)) < rangeLow or line.get_y1(array.get(h2Array, i)) > rangeHigh line.delete(array.get(h2Array, i))
for i=0 to array.size(h1Array) - 1 if line.get_y1(array.get(h1Array, i)) < rangeLow or line.get_y1(array.get(h1Array, i)) > rangeHigh line.delete(array.get(h1Array, i))
// Volume Profile Inputs var g_VP = "Volume Profile" rows = input.int(200, "Rows", tooltip = "The number of price levels/rows that will be used to approximate the cumulative volume profile", group = g_VP) tf = input.timeframe("D", "Profile Timeframe", tooltip = "The aggregate timeframe that the volume profile represents", group = g_VP) ltf = input.timeframe("1", "Resolution Timeframe", tooltip = "The timeframe whose price data will be used to build the volume profile", group = g_VP) extend = input.int(100, "Profile Extend %", 0, 100, tooltip = "How much the volume profile should extend to the next session", group = g_VP) vp_color = input.color(color.new(color.blue, 70), "Profile Color", tooltip = "The color of the volume profile", group = g_VP)
// Volume Point of Control Inputs var g_VPOC = "Volume Point of Control" show_vpoc = input.bool(true, "Show VPOC", inline = "VPOC", tooltip = "Whether to show the volume point of control (VPOC), or the level with the largest volume in a given volume profile", group = g_VPOC) vpoc_color = input.color(color.yellow, "", inline = "VPOC", group = g_VPOC) ext_vpoc = input.bool(true, "Extend Last N VPOCs", inline = "EXT", tooltip = "Whether to extend the last N number of VPOCs to the right of the chart", group = g_VPOC) ext_n_vpoc = input.int(5, "", 0, 100, inline = "EXT", group = g_VPOC) vpoc_label_above = input.timeframe("D", "Show Labels Above", tooltip = "With extend last N VPOCs turned on, labels displaying the date of said VPOCs will be shown when the profile timeframe is greater than or equal to this", group = g_VPOC) vpoc_label_size = input.string('Normal', "Label Size", options = ['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], tooltip = "The size of VPOC date labels", group = g_VPOC) vpoc_width = input.int(2, "Line Width", tooltip = "The width of VPOC lines", group = g_VPOC)
// High Volume Nodes Inputs var g_HVN = "High Volume Nodes" show_hvn = input.bool(true, "Show Previous HVNs", inline = "HVN", tooltip = "Whether to show high volume nodes (HVNs) from the previous session. Using the previous session's close, HVNs above this price will use the first color, and HVNs below this price will use the second color", group = g_HVN) hvn_color_bull = input.color(color.new(color.teal, 70), "", inline = "HVN", group = g_HVN) hvn_color_bear = input.color(color.new(color.red, 70), "", inline = "HVN", group = g_HVN) hvn_strength = input.int(10, "HVN Strength", tooltip = "HVNs are validated when a given level in the volume profile contains more volume than this many rows both above and below it", group = g_HVN) hvn_type = input.string("Areas", "HVN Type", options = ['Levels','Areas'], tooltip = "Whether to display HVNs as levels (lines) or areas (boxes). Levels use a solid line to denote the prior session's VPOC, and dotted lines for all other HVNs", group = g_HVN) hvn_width = input.int(1, "Line Width", tooltip = "The width of HVN lines, if the HVN type is selected as levels", group = g_HVN)
// Volume Profile Variables var vpoc = array.new_line() var dates = array.new_label() var values = array.new_float() var x_vol = array.new_int() var y_vol = array.new_float() var hvn_lines = array.new_line() var hvn_boxes = array.new_box() var hvn_Ly = array.new_float() var hvn_By = array.new_float() var PLA = array.new<chart.point>() var polyline PL = na var line temp_vpoc = na var int lb_idx = na var int lb_time = na
// Looping over the full array of lines and updating them, and deleting them if they have been touched size = array.size(levelBoxes) if size > 0 for i = 0 to size - 1 j = size - 1 - i box = array.get(levelBoxes, j) line = array.get(levelLines, j) level = line.get_y2(line) filled = (high >= level and low <= level)
if filled and extendtilfilled and not hidefilled array.remove(levelLines, j) array.remove(levelBoxes, j) continue
box.set_right(box, bar_index + 1) line.set_x2(line, bar_index + 1) if filled and hidefilled array.remove(levelLines, j) array.remove(levelBoxes, j) line.delete(line) box.delete(box)
if not filled and not extendtilfilled array.remove(levelLines, j) array.remove(levelBoxes, j) continue
// Deleting the oldest lines if array is too big if array.size(levelBoxes) >= 500 int i = 0 while array.size(levelBoxes) >= 500 box = array.get(levelBoxes, i) line = array.get(levelLines, i) box.delete(box) line.delete(line) array.remove(levelBoxes, i) array.remove(levelLines, i) i += 1
// Plotting circle labels for SPL plotshape(showhighs and showBubblesSPL and h and oitreshcond and voltreshcond and oicond ? high[swingSizeR] : na, style=shape.triangleup, location=location.absolute, offset=-swingSizeR, color=sellcolB, size=size.tiny) plotshape(showlows and showBubblesSPL and lv and oitreshcond and voltreshcond and oicond ? low[swingSizeR] : na, style=shape.triangledown, location=location.absolute, offset=-swingSizeR, color=buycolB, size=size.tiny)
conditionTiny = volumeCondition and normalizedVolume > 0 and normalizedVolume < 1 and showBubbles conditionSmall = volumeCondition and normalizedVolume >= 1 and normalizedVolume < 2 and showBubbles conditionNormal= volumeCondition and normalizedVolume >= 2 and normalizedVolume < 3 and showBubbles conditionLarge = volumeCondition and normalizedVolume >= 3 and normalizedVolume < 4 and showBubbles conditionHuge = volumeCondition and normalizedVolume >= 4 and showBubbles
// Plotting for Bubbles AcadAlgo if conditionHuge and (showLevels or showBubbles) label.new(showBubbles ? bar_index : last_bar_index, priceSource, str.tostring(selectedVolume, format.volume), xloc.bar_index, yloc.price, #00000000, showBubbles ? label.style_label_center : label.style_label_left, chart.fg_color)
if conditionHuge and showLevels line.new(bar_index, priceSource, last_bar_index, priceSource, xloc.bar_index, extend.none, gradientColor, width=2)
// Manage the number of lines and labels on the chart a_allLines = line.all if array.size(a_allLines) > levelsCount line.delete(array.shift(a_allLines))
a_allLabels = label.all if array.size(a_allLabels) > levelsCount and not showBubbles label.delete(array.shift(a_allLabels))
// Warning if no Volume data Provided if ta.cum(volume) <= 0 and barstate.islast label.new(bar_index, hl2, "No Volume Data Available\nUse Another Symbol", style=label.style_label_left, textcolor=chart.fg_color)
get_hvn() => if values.size() > hvn_strength for i = 0 to values.size() - 1 start = values.get(i) valid = true
for j = -hvn_strength to hvn_strength k = i + j if k < 0 or k > values.size() - 1 continue else if j != 0 and values.get(k) > start valid := false break
if valid idx = values.indexof(start)
if idx != -1 y1 = y_vol.get(idx) y2 = y_vol.get(idx) val = y_vol.get(idx)
if i < values.size() - 1 for m = i to values.size() - 2 if values.get(m + 1) > values.get(m) y1 := y_vol.get(m) break if i > 0 for m = i to 1 if values.get(m - 1) > values.get(m) y2 := y_vol.get(m) break
if timeframe.change(tf) or barstate.islast x_vol.clear() y_vol.clear() values.clear()
for i = 0 to rows y = y_min + i * (y_max - y_min) / rows x_vol.push(lb_time) y_vol.push(y) values.push(0)
for i = bar_index - lb_idx to 1 vol = ltf_V, if vol.size() > 0 for j = 0 to values.size() - 1 temp = y_vol.get(j) for k = 0 to vol.size() - 1 H = ltf_H L = ltf_L V = ltf_V if H.get(k) >= temp and L.get(k) <= temp add = math.floor(V.get(k) / ((H.get(k) - L.get(k)) / (y_max - y_min) / rows)) values.set(j, values.get(j) + add)
for j = 0 to values.size() - 1 set = (lb_time + math.floor(values.get(j) / sf)) x_vol.set(j, set)
PLA.clear() PLA.push(chart.point.from_time(lb_time, y_min)) for i = 0 to x_vol.size() - 1 PLA.push(chart.point.from_time(x_vol.get(i), y_vol.get(i))) PLA.push(chart.point.from_time(lb_time, y_max))
if timeframe.change(tf) lb_idx := bar_index lb_time := time
if show_hvn hvn_lines.clear() hvn_boxes.clear() hvn_Ly.clear() hvn_By.clear() get_hvn()
if ext_vpoc and vpoc.size() > ext_n_vpoc line.set_extend(vpoc.pop(), extend.none) if timeframe.in_seconds(tf) >= timeframe.in_seconds(vpoc_label_above) label.delete(dates.pop())
if dates.size() > 0 for i = 0 to dates.size() - 1 dates.get(i).set_x(bar_index + 20)
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının yazarı komut dosyasını açık kaynak olarak yayınlamıştır, böylece yatırımcılar betiği anlayabilir ve doğrulayabilir. Yazar çok yaşa! Ücretsiz olarak kullanabilirsiniz, ancak bu kodun yayında yeniden kullanımı Ev kurallarına tabidir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.
Bu komut dosyasını bir grafikte kullanmak ister misiniz?
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.