OPEN-SOURCE SCRIPT

Support & Resistance + Range Filter + Volume Profile

//version=5
indicator("Support & Resistance + Range Filter + Volume Profile [ChartPrime, DonovanWall, DGT]", overlay=true, max_boxes_count=500, max_lines_count=500, max_bars_back=5000)

// ---------------------------------------------------------------------------------------------------------------------}
// 𝙐𝙎𝙀𝙍 𝙄𝙉𝙋𝙐𝙉𝙏𝙎
// ---------------------------------------------------------------------------------------------------------------------{
// Support and Resistance Inputs
int lookbackPeriod = input.int(20, "Lookback Period", minval=1, group="Support & Resistance")
int vol_len = input.int(2, "Delta Volume Filter Length", tooltip="Higher input, will filter low volume boxes", group="Support & Resistance")
float box_width = input.float(1, "Adjust Box Width", maxval=1000, minval=0, step=0.1, group="Support & Resistance")

// Range Filter Inputs
src = input(close, title="Source", group="Range Filter")
per = input.int(100, minval=1, title="Sampling Period", group="Range Filter")
mult = input.float(3.0, minval=0.1, title="Range Multiplier", group="Range Filter")

// Range Filter Colors
upColor = input.color(color.white, "Up Color", group="Range Filter")
midColor = input.color(#90bff9, "Mid Color", group="Range Filter")
downColor = input.color(color.blue, "Down Color", group="Range Filter")

// Volume Profile Inputs
vpGR = 'Volume & Sentiment Profile'
vpSH = input.bool(true, 'Volume Profile', group=vpGR)
vpUC = input.color(color.new(#5d606b, 50), '  Up Volume ', inline='VP', group=vpGR)
vpDC = input.color(color.new(#d1d4dc, 50), 'Down Volume ', inline='VP', group=vpGR)
vaUC = input.color(color.new(#2962ff, 30), '  Value Area Up', inline='VA', group=vpGR)
vaDC = input.color(color.new(#fbc02d, 30), 'Value Area Down', inline='VA', group=vpGR)
spSH = input.bool(true, 'Sentiment Profile', group=vpGR)
spUC = input.color(color.new(#26a69a, 30), '  Bullish', inline='BB', group=vpGR)
spDC = input.color(color.new(#ef5350, 30), 'Bearish', inline='BB', group=vpGR)
sdSH = input.bool(true, 'Supply & Demand Zones', group=vpGR)
sdTH = input.int(15, '  Supply & Demand Threshold %', minval=0, maxval=41, group=vpGR) / 100
sdSC = input.color(color.new(#ec1313, 80), '  Supply Zones', inline='SD', group=vpGR)
sdDC = input.color(color.new(#0094FF, 80), 'Demand Zones', inline='SD', group=vpGR)
pcSH = input.string('Developing POC', 'Point of Control', options=['Developing POC', 'Last (Line)', 'None'], inline='POC', group=vpGR)
pocC = input.color(#f44336, '', inline='POC', group=vpGR)
pocW = input.int(2, '', minval=1, inline='POC', group=vpGR)
vpVA = input.float(68, 'Value Area (%)', minval=0, maxval=100, group=vpGR) / 100
vahS = input.bool(true, 'Value Area High (VAH)', inline='VAH', group=vpGR)
vahC = input.color(#2962ff, '', inline='VAH', group=vpGR)
vahW = input.int(1, '', minval=1, inline='VAH', group=vpGR)
vlSH = input.bool(true, 'Value Area Low (VAL)', inline='VAL', group=vpGR)
valC = input.color(#2962ff, '', inline='VAL', group=vpGR)
valW = input.int(1, '', minval=1, inline='VAL', group=vpGR)
vpPT = input.string('Bar Polarity', 'Profile Polarity Method', options=['Bar Polarity', 'Bar Buying/Selling Pressure'], group=vpGR)
vpLR = input.string('Fixed Range', 'Profile Lookback Range', options=['Fixed Range', 'Visible Range'], group=vpGR)
vpLN = input.int(360, 'Lookback Length / Fixed Range', minval=10, maxval=5000, step=10, group=vpGR)
vpST = input.bool(true, 'Profile Stats', inline='STT', group=vpGR)
ppLS = input.string('Small', "", options=['Tiny', 'Small', 'Normal'], inline='STT', group=vpGR)
lcDB = input.string('Top Right', '', options=['Top Right', 'Middle Right', 'Bottom Left'], inline='STT', group=vpGR)
vpLV = input.bool(true, 'Profile Price Levels', inline='BBe', group=vpGR)
rpLS = input.string('Small', "", options=['Tiny', 'Small', 'Normal'], inline='BBe', group=vpGR)
vpPL = input.string('Right', 'Profile Placement', options=['Right', 'Left'], group=vpGR)
vpNR = input.int(100, 'Profile Number of Rows', minval=10, maxval=150, step=10, group=vpGR)
vpWD = input.float(31, 'Profile Width', minval=0, maxval=250, group=vpGR) / 100
vpHO = input.int(13, 'Profile Horizontal Offset', maxval=50, group=vpGR)
vaBG = input.bool(false, 'Value Area Background  ', inline='vBG', group=vpGR)
vBGC = input.color(color.new(#2962ff, 89), '', inline='vBG', group=vpGR)
vpBG = input.bool(false, 'Profile Range Background ', inline='pBG', group=vpGR)
bgC = input.color(color.new(#2962ff, 95), '', inline='pBG', group=vpGR)
vhGR = 'Volume Histogram'
vhSH = input.bool(true, 'Volume Histogram', group=vhGR)
vmaS = input.bool(true, 'Volume MA,         Length', inline='vol2', group=vhGR)
vmaL = input.int(21, '', minval=1, inline='vol2', group=vhGR)
vhUC = input.color(color.new(#26a69a, 30), '  Growing', inline='vol1', group=vhGR)
vhDC = input.color(color.new(#ef5350, 30), 'Falling', inline='vol1', group=vhGR)
vmaC = input.color(color.new(#2962ff, 0), 'Volume MA', inline='vol1', group=vhGR)
vhPL = input.string('Top', '  Placement', options=['Top', 'Bottom'], group=vhGR)
vhHT = 11 - input.int(8, '  Hight', minval=1, maxval=10, group=vhGR)
vhVO = input.int(1, '  Vertical Offset', minval=0, maxval=20, group=vhGR) / 20
cbGR = 'Volume Weighted Colored Bars'
vwcb = input.bool(false, 'Volume Weighted Colored Bars', group=cbGR)
upTH = input.float(1.618, '  Upper Threshold', minval=1., step=.1, group=cbGR)
dnTH = input.float(0.618, '  Lower Threshold', minval=.1, step=.1, group=cbGR)

// ---------------------------------------------------------------------------------------------------------------------}
// 𝙎𝙐𝙋𝙋𝙊𝙍𝙏 𝘼𝙉𝘿 𝙍𝙀𝙎𝙄𝙎𝙏𝘼𝙉𝘾𝙀 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// ---------------------------------------------------------------------------------------------------------------------{
// Delta Volume Function
upAndDownVolume() =>
posVol = 0.0
negVol = 0.0
var isBuyVolume = true
switch
close > open => isBuyVolume := true
close < open => isBuyVolume := false
if isBuyVolume
posVol += volume
else
negVol -= volume
posVol + negVol

// Function to identify support and resistance boxes
calcSupportResistance(src, lookbackPeriod) =>
Vol = upAndDownVolume()
vol_hi = ta.highest(Vol/2.5, vol_len)
vol_lo = ta.lowest(Vol/2.5, vol_len)

var float supportLevel = na
var float resistanceLevel = na
var box sup = na
var box res = na
var color res_color = na
var color sup_color = na

// Find pivot points
pivotHigh = ta.pivothigh(src, lookbackPeriod, lookbackPeriod)
pivotLow = ta.pivotlow (src, lookbackPeriod, lookbackPeriod)
atr = ta.atr(200)
withd = atr * box_width

// Find support levels with Positive Volume
if (not na(pivotLow)) and Vol > vol_hi
supportLevel := pivotLow
topLeft = chart.point.from_index(bar_index-lookbackPeriod, supportLevel)
bottomRight = chart.point.from_index(bar_index, supportLevel-withd)
sup_color := color.from_gradient(Vol, 0, ta.highest(Vol, 25), color(na), color.new(color.green, 30))
sup := box.new(topLeft, bottomRight, border_color=color.green, border_width=1, bgcolor=sup_color, text="Vol: "+str.tostring(math.round(Vol,2)), text_color=chart.fg_color, text_size=size.small)

// Find resistance levels with Negative Volume
if (not na(pivotHigh)) and Vol < vol_lo
resistanceLevel := pivotHigh
topLeft = chart.point.from_index(bar_index-lookbackPeriod, resistanceLevel)
bottomRight = chart.point.from_index(bar_index, resistanceLevel+withd)
res_color := color.from_gradient(Vol, ta.lowest(Vol, 25), 0, color.new(color.red, 30), color(na))
res := box.new(topLeft, bottomRight, border_color=color.red, border_width=1, bgcolor=res_color, text="Vol: "+str.tostring(math.round(Vol,2)), text_color=chart.fg_color, text_size=size.small)

[supportLevel, resistanceLevel]

[supportLevel, resistanceLevel] = calcSupportResistance(close, lookbackPeriod)

// ---------------------------------------------------------------------------------------------------------------------}
// 𝙍𝘼𝙉𝙂𝙀 𝙁𝙄𝙇𝙏𝙀𝙍 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// ---------------------------------------------------------------------------------------------------------------------{
// Smooth Average Range
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(src, per, mult)

// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)

// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

// Target Bands
hband = filt + smrng
lband = filt - smrng

// Colors
filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor
barcolor = src > filt and src > src[1] and upward > 0 ? upColor :
src > filt and src < src[1] and upward > 0 ? upColor :
src < filt and src < src[1] and downward > 0 ? downColor :
src < filt and src > src[1] and downward > 0 ? downColor : midColor

filtplot = plot(filt, color=filtcolor, linewidth=2, title="Range Filter")
hbandplot = plot(hband, color=color.new(upColor, 70), title="High Target")
lbandplot = plot(lband, color=color.new(downColor, 70), title="Low Target")

// Fills
fill(hbandplot, filtplot, color=color.new(upColor, 90), title="High Target Range")
fill(lbandplot, filtplot, color=color.new(downColor, 90), title="Low Target Range")

// Break Outs
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or
src > filt and src < src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or
src < filt and src > src[1] and downward > 0

CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1

// Plot Buy/Sell Signals
plotshape(longCondition, title="Buy Signal", text="Buy", textcolor=color.white, style=shape.labelup, size=size.small, location=location.belowbar, color=color.new(#aaaaaa, 20))
plotshape(shortCondition, title="Sell Signal", text="Sell", textcolor=color.white, style=shape.labeldown, size=size.small, location=location.abovebar, color=color.new(downColor, 20))

// ---------------------------------------------------------------------------------------------------------------------}
// 𝙑𝙊𝙇𝙐𝙈𝙀 𝙋𝙍𝙊𝙁𝙄𝙇𝙀 𝘾𝘼𝙇𝘾𝙐𝙇𝘼𝙏𝙄𝙊𝙉𝙎
// ---------------------------------------------------------------------------------------------------------------------{
// (Include the Volume Profile calculations and visualizations from the original script here)
// ...

// ---------------------------------------------------------------------------------------------------------------------}
// 𝙑𝙄𝙎𝙐𝘼𝙇𝙄𝙕𝘼𝙏𝙄𝙊𝙉
// ---------------------------------------------------------------------------------------------------------------------{
// (Include the visualization logic from the Volume Profile script here)
// ...

// ---------------------------------------------------------------------------------------------------------------------}
// 𝘼𝙇𝙀𝙍𝙏𝙎
// ---------------------------------------------------------------------------------------------------------------------{
// (Include the alert conditions from the Volume Profile script here)
// ...

// ---------------------------------------------------------------------------------------------------------------------}
Bands and ChannelsBill Williams IndicatorsBreadth Indicators

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?

Exención de responsabilidad