OPEN-SOURCE SCRIPT

AI Liquidity Confirmation Framework [Signals + RR]

284
//version=6
indicator("AI Liquidity Confirmation Framework [Signals + RR]", overlay=true)

// ----------------------
// Inputs
// ----------------------
atrLen = input.int(14, "ATR Length")
rr = input.float(2.0, "Risk Reward", step=0.25)
confirmBars = input.int(1, "Confirmation Bars")

// ----------------------
// Core Calculations
// ----------------------
atr = ta.atr(atrLen)

// Liquidity levels (simple swing logic)
sellLiquidity = ta.highest(high, 10)
buyLiquidity = ta.lowest(low, 10)

// Sweep detection
sellSweep = high > sellLiquidity[1] and close < sellLiquidity[1]
buySweep = low < buyLiquidity[1] and close > buyLiquidity[1]

// Confirmation candles
bullConfirm = close > open and close > close[1]
bearConfirm = close < open and close < close[1]

// ----------------------
// Trade Logic
// ----------------------
buySignal = buySweep and bullConfirm
sellSignal = sellSweep and bearConfirm

// Risk management
buyStop = low - atr
sellStop = high + atr

buyTarget = close + (close - buyStop) * rr
sellTarget = close - (sellStop - close) * rr

// ----------------------
// Plot Signals
// ----------------------
plotshape(buySignal, title="BUY", style=shape.labelup, text="BUY", color=color.new(color.green, 0))
plotshape(sellSignal, title="SELL", style=shape.labeldown, text="SELL", color=color.new(color.red, 0))

// Stops & Targets
plot(buySignal ? buyStop : na, color=color.red, style=plot.style_linebr)
plot(buySignal ? buyTarget : na, color=color.green, style=plot.style_linebr)

plot(sellSignal ? sellStop : na, color=color.red, style=plot.style_linebr)
plot(sellSignal ? sellTarget : na, color=color.green, style=plot.style_linebr)

// ----------------------
// WAIT State
// ----------------------
waitState = not buySignal and not sellSignal
plotchar(waitState, title="WAIT", char=".", location=location.top, color=color.gray)

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.