OPEN-SOURCE SCRIPT

kezio

//version=5
indicator("Smart Money Concept SMC", overlay=true)

// Configurações do usuário
length = input(20, title="Período para estrutura")
sensitivity = input(2, title="Sensibilidade BOS")

// Cálculo de Highs e Lows
highs = ta.highest(high, length)
lows = ta.lowest(low, length)

// Detecção de Break of Structure (BOS)
BOS_Bullish = ta.crossover(high, ta.highest(high, sensitivity))
BOS_Bearish = ta.crossunder(low, ta.lowest(low, sensitivity))

// Detecção de Change of Character (CHOCH)
CHOCH_Bullish = ta.crossover(high, ta.lowest(low, sensitivity))
CHOCH_Bearish = ta.crossunder(low, ta.highest(high, sensitivity))

// Identificação de Liquidity Grabs
liquidity_grab_bullish = ta.lowest(low, sensitivity)[1] < low and close > open
liquidity_grab_bearish = ta.highest(high, sensitivity)[1] > high and close < open

// Marcação das Zonas de Oferta e Demanda
var float demandZone = na
var float supplyZone = na
if BOS_Bullish
demandZone := ta.lowest(low, sensitivity)
if BOS_Bearish
supplyZone := ta.highest(high, sensitivity)

// Plotando os sinais
plotshape(BOS_Bullish, location=location.belowbar, color=color.green, style=shape.labelup, title="BOS Up")
plotshape(BOS_Bearish, location=location.abovebar, color=color.red, style=shape.labeldown, title="BOS Down")
plotshape(CHOCH_Bullish, location=location.belowbar, color=color.blue, style=shape.triangleup, title="CHOCH Up")
plotshape(CHOCH_Bearish, location=location.abovebar, color=color.orange, style=shape.triangledown, title="CHOCH Down")
plotshape(liquidity_grab_bullish, location=location.belowbar, color=color.purple, style=shape.circle, title="Liquidity Grab Buy")
plotshape(liquidity_grab_bearish, location=location.abovebar, color=color.purple, style=shape.circle, title="Liquidity Grab Sell")

// Desenha zonas institucionais
bgcolor(BOS_Bullish ? color.green : na, transp=90)
bgcolor(BOS_Bearish ? color.red : na, transp=90)

כתב ויתור