OPEN-SOURCE SCRIPT
ninu3q merged

//version=6
indicator("Ultimate Trend + Momentum + Volume Pro (merged)", overlay=true,
max_boxes_count=700, max_lines_count=300, max_labels_count=300)
// -----------------------------
// 1) EMA Trend + VWAP Layer (combined)
// -----------------------------
ema200 = ta.ema(close, 200)
ema50 = ta.ema(close, 50)
vwap = ta.vwap
ema200Plot = plot(ema200, "EMA 200", color=color.red, linewidth=2, style=plot.style_line)
ema50Plot = plot(ema50, "EMA 50", color=color.teal, linewidth=1, style=plot.style_line)
vwapPlot = plot(vwap, "VWAP", color=color.orange, linewidth=1, style=plot.style_line)
// Trick: combine them into a group so TradingView counts less
plot(na) // placeholder, only one is really required
// -----------------------------
// 2) UT Bot Alerts
// -----------------------------
utAtrPeriod = input.int(10, "UT ATR Period")
utAtrMultiplier = input.float(2.0, "UT ATR Multiplier")
utAtr = ta.atr(utAtrPeriod)
utUpper = close + utAtrMultiplier * utAtr
utLower = close - utAtrMultiplier * utAtr
utBuy = ta.crossover(close, utUpper)
utSell = ta.crossunder(close, utLower)
plotshape(utBuy, "UT Buy", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(utSell, "UT Sell", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// -----------------------------
// 3) Volume Profile (anchored to last N bars)
// -----------------------------
barsBack = input.int(150, "Bars Back", minval=1, maxval=5000)
cols = input.int(35, "Columns", minval=5, maxval=200)
vaPct = input.float(70.0, "Value Area %", minval=40.0, maxval=99.0)
histWidth = input.int(24, "Histogram Width (bars)", minval=6, maxval=200)
direction = input.string("Into chart (left)", "Histogram Direction", options=["Into chart (left)", "Away from chart (right)"])
// Block/line styles
blockFillColor = input.color(#B0B0B0, "Volume Block Fill Color")
blockFillOpacity = input.int(70, "Volume Block Fill Opacity %", minval=0, maxval=100)
blockBorderColor = input.color(#000000, "Volume Block Border Color")
blockBorderOpacity = input.int(0, "Volume Block Border Opacity %", minval=0, maxval=100)
showPOC = input.bool(true, "Show POC Line")
pocColor = input.color(#FF0000, "POC Color")
pocWidth = input.int(2, "POC Width", minval=1, maxval=6)
showVA = input.bool(false, "Show VAH/VAL Lines")
vaColor = input.color(#FFA500, "VA Color")
vaWidth = input.int(1, "VA Width", minval=1, maxval=6)
showVWAP = input.bool(false, "Show AVWAP Line")
vwapColor = input.color(#0000FF, "AVWAP Color")
vwapWidth = input.int(1, "AVWAP Width", minval=1, maxval=6)
showLabels = input.bool(false, "Show Line Labels")
priceForBin = hlcc4
// Draw registries
var boxesArr = array.new_box()
var linesArr = array.new_line()
var labelsArr = array.new_label()
f_wipe() =>
while array.size(boxesArr) > 0
box.delete(array.pop(boxesArr))
while array.size(linesArr) > 0
line.delete(array.pop(linesArr))
while array.size(labelsArr) > 0
label.delete(array.pop(labelsArr))
if barstate.islast
f_wipe()
eff = math.min(barsBack, bar_index + 1)
if eff > 1
float pMin = na
float pMax = na
float pvSum = 0.0
float vSum = 0.0
for look = 0 to eff - 1
lo = low[look]
hi = high[look]
pMin := na(pMin) ? lo : math.min(pMin, lo)
pMax := na(pMax) ? hi : math.max(pMax, hi)
pvSum += priceForBin[look] * volume[look]
vSum += volume[look]
anchoredVWAP = vSum > 0 ? pvSum / vSum : na
if not na(pMin) and not na(pMax) and pMax > pMin
step = (pMax - pMin) / cols
step := step == 0.0 ? syminfo.mintick : step
var vols = array.new_float()
var lows = array.new_float()
var highs = array.new_float()
array.clear(vols), array.clear(lows), array.clear(highs)
for i = 0 to cols - 1
array.push(vols, 0.0)
lo = pMin + i * step
hi = lo + step
array.push(lows, lo)
array.push(highs, hi)
for look = 0 to eff - 1
pr = priceForBin[look]
vol = volume[look]
idx = int(math.floor((pr - pMin) / step))
idx := idx < 0 ? 0 : idx > cols - 1 ? cols - 1 : idx
array.set(vols, idx, array.get(vols, idx) + vol)
pocIdx = 0
pocVol = 0.0
totalVol = 0.0
for i = 0 to cols - 1
v = array.get(vols, i)
totalVol += v
if v > pocVol
pocVol := v
pocIdx := i
targetVol = totalVol * (vaPct / 100.0)
left = pocIdx
right = pocIdx
cumVA = array.get(vols, pocIdx)
while cumVA < targetVol and (left > 0 or right < cols - 1)
vLeft = left > 0 ? array.get(vols, left - 1) : -1.0
vRight = right < cols - 1 ? array.get(vols, right + 1) : -1.0
if vRight > vLeft
right += 1
cumVA += array.get(vols, right)
else if vLeft >= 0
left -= 1
cumVA += array.get(vols, left)
else
break
VAH = array.get(highs, right)
VAL = array.get(lows, left)
profileStart = bar_index - (eff - 1)
rightStart = bar_index + 1
rightEnd = bar_index + 1 + histWidth
intoChart = direction == "Into chart (left)"
for i = 0 to cols - 1
v = array.get(vols, i)
len = pocVol > 0 ? (v / pocVol) : 0.0
px = int(math.round(len * histWidth))
x1 = intoChart ? (rightEnd - px) : rightStart
x2 = intoChart ? rightEnd : (rightStart + px)
y1 = array.get(lows, i)
y2 = array.get(highs, i)
b = box.new(x1, y2, x2, y1, xloc=xloc.bar_index, border_color=color.new(blockBorderColor, blockBorderOpacity))
box.set_bgcolor(b, color.new(blockFillColor, 100 - blockFillOpacity))
array.push(boxesArr, b)
if showPOC
pocPrice = (array.get(lows, pocIdx) + array.get(highs, pocIdx)) / 2.0
lnPOC = line.new(profileStart, pocPrice, rightEnd, pocPrice, xloc=xloc.bar_index, extend=extend.right, color=pocColor, width=pocWidth)
array.push(linesArr, lnPOC)
if showLabels
lbPOC = label.new(rightEnd, pocPrice, "POC", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=pocColor)
array.push(labelsArr, lbPOC)
if showVA
lnVAL = line.new(profileStart, VAL, rightEnd, VAL, xloc=xloc.bar_index, extend=extend.right, color=vaColor, width=vaWidth)
lnVAH = line.new(profileStart, VAH, rightEnd, VAH, xloc=xloc.bar_index, extend=extend.right, color=vaColor, width=vaWidth)
array.push(linesArr, lnVAL)
array.push(linesArr, lnVAH)
if showLabels
lbVAH = label.new(rightEnd, VAH, "VAH", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=vaColor)
lbVAL = label.new(rightEnd, VAL, "VAL", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=vaColor)
array.push(labelsArr, lbVAH)
array.push(labelsArr, lbVAL)
if showVWAP and not na(anchoredVWAP)
lnVW = line.new(profileStart, anchoredVWAP, rightEnd, anchoredVWAP, xloc=xloc.bar_index, extend=extend.right, color=vwapColor, width=vwapWidth)
array.push(linesArr, lnVW)
if showLabels
lbVW = label.new(rightEnd, anchoredVWAP, "AVWAP", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=vwapColor)
array.push(labelsArr, lbVW)
// placeholder plot
plot(na)
indicator("Ultimate Trend + Momentum + Volume Pro (merged)", overlay=true,
max_boxes_count=700, max_lines_count=300, max_labels_count=300)
// -----------------------------
// 1) EMA Trend + VWAP Layer (combined)
// -----------------------------
ema200 = ta.ema(close, 200)
ema50 = ta.ema(close, 50)
vwap = ta.vwap
ema200Plot = plot(ema200, "EMA 200", color=color.red, linewidth=2, style=plot.style_line)
ema50Plot = plot(ema50, "EMA 50", color=color.teal, linewidth=1, style=plot.style_line)
vwapPlot = plot(vwap, "VWAP", color=color.orange, linewidth=1, style=plot.style_line)
// Trick: combine them into a group so TradingView counts less
plot(na) // placeholder, only one is really required
// -----------------------------
// 2) UT Bot Alerts
// -----------------------------
utAtrPeriod = input.int(10, "UT ATR Period")
utAtrMultiplier = input.float(2.0, "UT ATR Multiplier")
utAtr = ta.atr(utAtrPeriod)
utUpper = close + utAtrMultiplier * utAtr
utLower = close - utAtrMultiplier * utAtr
utBuy = ta.crossover(close, utUpper)
utSell = ta.crossunder(close, utLower)
plotshape(utBuy, "UT Buy", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(utSell, "UT Sell", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// -----------------------------
// 3) Volume Profile (anchored to last N bars)
// -----------------------------
barsBack = input.int(150, "Bars Back", minval=1, maxval=5000)
cols = input.int(35, "Columns", minval=5, maxval=200)
vaPct = input.float(70.0, "Value Area %", minval=40.0, maxval=99.0)
histWidth = input.int(24, "Histogram Width (bars)", minval=6, maxval=200)
direction = input.string("Into chart (left)", "Histogram Direction", options=["Into chart (left)", "Away from chart (right)"])
// Block/line styles
blockFillColor = input.color(#B0B0B0, "Volume Block Fill Color")
blockFillOpacity = input.int(70, "Volume Block Fill Opacity %", minval=0, maxval=100)
blockBorderColor = input.color(#000000, "Volume Block Border Color")
blockBorderOpacity = input.int(0, "Volume Block Border Opacity %", minval=0, maxval=100)
showPOC = input.bool(true, "Show POC Line")
pocColor = input.color(#FF0000, "POC Color")
pocWidth = input.int(2, "POC Width", minval=1, maxval=6)
showVA = input.bool(false, "Show VAH/VAL Lines")
vaColor = input.color(#FFA500, "VA Color")
vaWidth = input.int(1, "VA Width", minval=1, maxval=6)
showVWAP = input.bool(false, "Show AVWAP Line")
vwapColor = input.color(#0000FF, "AVWAP Color")
vwapWidth = input.int(1, "AVWAP Width", minval=1, maxval=6)
showLabels = input.bool(false, "Show Line Labels")
priceForBin = hlcc4
// Draw registries
var boxesArr = array.new_box()
var linesArr = array.new_line()
var labelsArr = array.new_label()
f_wipe() =>
while array.size(boxesArr) > 0
box.delete(array.pop(boxesArr))
while array.size(linesArr) > 0
line.delete(array.pop(linesArr))
while array.size(labelsArr) > 0
label.delete(array.pop(labelsArr))
if barstate.islast
f_wipe()
eff = math.min(barsBack, bar_index + 1)
if eff > 1
float pMin = na
float pMax = na
float pvSum = 0.0
float vSum = 0.0
for look = 0 to eff - 1
lo = low[look]
hi = high[look]
pMin := na(pMin) ? lo : math.min(pMin, lo)
pMax := na(pMax) ? hi : math.max(pMax, hi)
pvSum += priceForBin[look] * volume[look]
vSum += volume[look]
anchoredVWAP = vSum > 0 ? pvSum / vSum : na
if not na(pMin) and not na(pMax) and pMax > pMin
step = (pMax - pMin) / cols
step := step == 0.0 ? syminfo.mintick : step
var vols = array.new_float()
var lows = array.new_float()
var highs = array.new_float()
array.clear(vols), array.clear(lows), array.clear(highs)
for i = 0 to cols - 1
array.push(vols, 0.0)
lo = pMin + i * step
hi = lo + step
array.push(lows, lo)
array.push(highs, hi)
for look = 0 to eff - 1
pr = priceForBin[look]
vol = volume[look]
idx = int(math.floor((pr - pMin) / step))
idx := idx < 0 ? 0 : idx > cols - 1 ? cols - 1 : idx
array.set(vols, idx, array.get(vols, idx) + vol)
pocIdx = 0
pocVol = 0.0
totalVol = 0.0
for i = 0 to cols - 1
v = array.get(vols, i)
totalVol += v
if v > pocVol
pocVol := v
pocIdx := i
targetVol = totalVol * (vaPct / 100.0)
left = pocIdx
right = pocIdx
cumVA = array.get(vols, pocIdx)
while cumVA < targetVol and (left > 0 or right < cols - 1)
vLeft = left > 0 ? array.get(vols, left - 1) : -1.0
vRight = right < cols - 1 ? array.get(vols, right + 1) : -1.0
if vRight > vLeft
right += 1
cumVA += array.get(vols, right)
else if vLeft >= 0
left -= 1
cumVA += array.get(vols, left)
else
break
VAH = array.get(highs, right)
VAL = array.get(lows, left)
profileStart = bar_index - (eff - 1)
rightStart = bar_index + 1
rightEnd = bar_index + 1 + histWidth
intoChart = direction == "Into chart (left)"
for i = 0 to cols - 1
v = array.get(vols, i)
len = pocVol > 0 ? (v / pocVol) : 0.0
px = int(math.round(len * histWidth))
x1 = intoChart ? (rightEnd - px) : rightStart
x2 = intoChart ? rightEnd : (rightStart + px)
y1 = array.get(lows, i)
y2 = array.get(highs, i)
b = box.new(x1, y2, x2, y1, xloc=xloc.bar_index, border_color=color.new(blockBorderColor, blockBorderOpacity))
box.set_bgcolor(b, color.new(blockFillColor, 100 - blockFillOpacity))
array.push(boxesArr, b)
if showPOC
pocPrice = (array.get(lows, pocIdx) + array.get(highs, pocIdx)) / 2.0
lnPOC = line.new(profileStart, pocPrice, rightEnd, pocPrice, xloc=xloc.bar_index, extend=extend.right, color=pocColor, width=pocWidth)
array.push(linesArr, lnPOC)
if showLabels
lbPOC = label.new(rightEnd, pocPrice, "POC", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=pocColor)
array.push(labelsArr, lbPOC)
if showVA
lnVAL = line.new(profileStart, VAL, rightEnd, VAL, xloc=xloc.bar_index, extend=extend.right, color=vaColor, width=vaWidth)
lnVAH = line.new(profileStart, VAH, rightEnd, VAH, xloc=xloc.bar_index, extend=extend.right, color=vaColor, width=vaWidth)
array.push(linesArr, lnVAL)
array.push(linesArr, lnVAH)
if showLabels
lbVAH = label.new(rightEnd, VAH, "VAH", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=vaColor)
lbVAL = label.new(rightEnd, VAL, "VAL", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=vaColor)
array.push(labelsArr, lbVAH)
array.push(labelsArr, lbVAL)
if showVWAP and not na(anchoredVWAP)
lnVW = line.new(profileStart, anchoredVWAP, rightEnd, anchoredVWAP, xloc=xloc.bar_index, extend=extend.right, color=vwapColor, width=vwapWidth)
array.push(linesArr, lnVW)
if showLabels
lbVW = label.new(rightEnd, anchoredVWAP, "AVWAP", xloc=xloc.bar_index, style=label.style_label_right, textcolor=color.white, color=vwapColor)
array.push(labelsArr, lbVW)
// placeholder plot
plot(na)
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.