OPEN-SOURCE SCRIPT

Buy/Sell Side Liquidity

//version=5
indicator("Buy/Sell Side Liquidity", overlay=true)

// Parámetros
lookback_high = input.int(20, title="Buscar Máximos (Buy Side)", minval=1)
lookback_low = input.int(20, title="Buscar Mínimos (Sell Side)", minval=1)
show_labels = input.bool(true, title="Mostrar Etiquetas")

// Detectar máximos y mínimos recientes
highest_price = ta.highest(high, lookback_high)
lowest_price = ta.lowest(low, lookback_low)

// Detectar barras donde aparecen los máximos y mínimos
high_bar = ta.highestbars(high, lookback_high)
low_bar = ta.lowestbars(low, lookback_low)

// Dibujar líneas en las zonas de Buy/Sell Side Liquidity
bsl_line = line.new(x1=bar_index - lookback_high, y1=highest_price, x2=bar_index, y2=highest_price, color=color.new(color.blue, 70), width=2, extend=extend.right, style=line.style_dotted)
ssl_line = line.new(x1=bar_index - lookback_low, y1=lowest_price, x2=bar_index, y2=lowest_price, color=color.new(color.red, 70), width=2, extend=extend.right, style=line.style_dotted)

// Etiquetas opcionales para identificar zonas de liquidez
if show_labels
label.new(bar_index[high_bar], highest_price, "BSL", style=label.style_label_down, color=color.blue, textcolor=color.white)
label.new(bar_index[low_bar], lowest_price, "SSL", style=label.style_label_up, color=color.red, textcolor=color.white)
Candlestick analysisChart patternsFundamental Analysis

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer