// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © alexgrover //@version=6 indicator('Kênh giá pivot', 'Pivot Bands - Việt hoá bởi Code2trade', overlay = true, max_bars_back = 5000) //---- length = input(100, 'Số lượng nến tính toán') astart = input(1, 'Vị trí A-High', tooltip = 'Vẽ trend từ 2 đỉnh gần nhất thì A high = 1 và B high = 0. Nếu vẽ trend từ 3 đỉnh gần nhất thì A high = 2 và B = 0') aend = input(0, 'Vị trí B-High ') bstart = input(1, 'Vị trí A-Low ') bend = input(0, 'Vị trí B-Low ') csrc = input(false, 'Dùng nguồn tính toán khác?') src = input(close, 'Custom Source') //---- up = ta.pivothigh(csrc ? src : high, length, length) dn = ta.pivotlow(csrc ? src : low, length, length) //---- n = bar_index a1 = ta.valuewhen(not na(up), n, astart) b1 = ta.valuewhen(not na(dn), n, bstart) a2 = ta.valuewhen(not na(up), n, aend) b2 = ta.valuewhen(not na(dn), n, bend) //---- line upper = line.new(n[n - a1 + length], up[n - a1], n[n - a2 + length], up[n - a2], extend = extend.right, color = color.blue, width = 2) line lower = line.new(n[n - b1 + length], dn[n - b1], n[n - b2 + length], dn[n - b2], extend = extend.right, color = color.orange, width = 2) line.delete(upper[1]) line.delete(lower[1]) //---- label ahigh = label.new(n[n - a1 + length], up[n - a1], 'A-High', color = color.blue, style = label.style_label_down, textcolor = color.white, size = size.small) label bhigh = label.new(n[n - a2 + length], up[n - a2], 'B-High', color = color.blue, style = label.style_label_down, textcolor = color.white, size = size.small) label alow = label.new(n[n - b1 + length], dn[n - b1], 'A-Low', color = color.orange, style = label.style_label_up, textcolor = color.white, size = size.small) label blow = label.new(n[n - b2 + length], dn[n - b2], 'B-Low', color = color.orange, style = label.style_label_up, textcolor = color.white, size = size.small) label.delete(ahigh[1]) label.delete(bhigh[1]) label.delete(alow[1]) label.delete(blow[1]) //---- plot(up, 'Pivot High\'s', color.new(color.blue, 0), 4, style = plot.style_circles, offset = -length, join = true) plot(dn, 'Pivot Low\'s', color.new(color.orange, 0), 4, style = plot.style_circles, offset = -length, join = true)