Smart Money Absorption Radar | Thomas

Thomas-Sterling · study · 260 行 · 点赞 1,470 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Thomas-Sterling
 
 
 // This Pine Script® code is subject to the terms of the Mozilla Public License 2.0
 // © Thomas-Sterling
 
//@version=6
indicator("Smart Money Absorption Radar | Thomas", overlay=true, max_labels_count=100, max_boxes_count=20, max_lines_count=30)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 01. USER SETTINGS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
groupAbs = "Absorption Engine"
volLength = input.int(20, "Volume Average Length", minval=5, group=groupAbs)
volMultiplier = input.float(1.5, "Volume Spike Multiplier", minval=1.0, step=0.1, group=groupAbs)
wickRatio = input.float(0.40, "Minimum Rejection Wick Ratio", minval=0.1, maxval=0.9, step=0.05, group=groupAbs)
rangeLength = input.int(20, "Liquidity Lookback", minval=5, group=groupAbs)
 
groupFilter = "Signal Filters"
useTrendFilter = input.bool(false, "Use EMA Trend Filter", group=groupFilter)
emaLength = input.int(200, "EMA Length", minval=20, group=groupFilter)
useSweepFilter = input.bool(false, "Require Liquidity Sweep", group=groupFilter)
cooldown = input.int(8, "Signal Cooldown Bars", minval=0, group=groupFilter)
 
groupVisual = "Chart Visuals"
showZones = input.bool(true, "Show Absorption Zones", group=groupVisual)
showSweep = input.bool(true, "Show Liquidity Sweeps", group=groupVisual)
showEMA = input.bool(false, "Show EMA", group=groupVisual)
showSignals = input.bool(true, "Show BUY / SELL Signals", group=groupVisual)
zoneExtension = input.int(20, "Zone Extension Bars", minval=1, maxval=200, group=groupVisual)
 
groupDash = "Radar Dashboard"
showDashboard = input.bool(true, "Show Dashboard", group=groupDash)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 02. VOLUME AND PRICE ANALYSIS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
atr = ta.atr(14)
ema = ta.ema(close, emaLength)
avgVolume = ta.sma(volume, volLength)
 
validVolume = not na(volume) and not na(avgVolume) and avgVolume > 0
volumeSpike = validVolume and volume >= avgVolume * volMultiplier
 
candleRange = math.max(high - low, syminfo.mintick)
body = math.abs(close - open)
 
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low
 
upperWickRatio = upperWick / candleRange
lowerWickRatio = lowerWick / candleRange
 
closePosition = (close - low) / candleRange
 
bullRejection = lowerWickRatio >= wickRatio and closePosition >= 0.60
bearRejection = upperWickRatio >= wickRatio and closePosition <= 0.40
 
plot(showEMA ? ema : na, "Trend EMA", color=color.orange, linewidth=2)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 03. LIQUIDITY SWEEP ENGINE
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
previousLow = ta.lowest(low[1], rangeLength)
previousHigh = ta.highest(high[1], rangeLength)
 
bullSweep = not na(previousLow) and low < previousLow and close > previousLow
bearSweep = not na(previousHigh) and high > previousHigh and close < previousHigh
 
plotshape(showSweep and bullSweep and barstate.isconfirmed, title="Bullish Liquidity Sweep", style=shape.triangleup, location=location.belowbar, color=color.aqua, size=size.tiny, text="SW")
plotshape(showSweep and bearSweep and barstate.isconfirmed, title="Bearish Liquidity Sweep", style=shape.triangledown, location=location.abovebar, color=color.orange, size=size.tiny, text="SW")
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 04. ABSORPTION DETECTION
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
// Estimated price-volume absorption.
// Pine does not provide universal historical bid/ask order flow.
 
bullAbsorption = volumeSpike and bullRejection
bearAbsorption = volumeSpike and bearRejection
 
trendBull = not useTrendFilter or close > ema
trendBear = not useTrendFilter or close < ema
 
sweepBullValid = not useSweepFilter or bullSweep
sweepBearValid = not useSweepFilter or bearSweep
 
rawBuy = bullAbsorption and trendBull and sweepBullValid
rawSell = bearAbsorption and trendBear and sweepBearValid
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 05. SIGNAL COOLDOWN
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
var int lastSignalBar = na
 
cooldownPassed = na(lastSignalBar) or bar_index - lastSignalBar > cooldown
 
buySignal = rawBuy and cooldownPassed and barstate.isconfirmed
sellSignal = rawSell and cooldownPassed and barstate.isconfirmed
 
if buySignal or sellSignal
    lastSignalBar := bar_index
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 06. ABSORPTION ZONES
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
var box bullZone = na
var box bearZone = na
 
if showZones and buySignal
    if not na(bullZone)
        box.delete(bullZone)
    bullZone := box.new(left=bar_index, top=math.max(open, close), right=bar_index + zoneExtension, bottom=low, border_color=color.new(color.aqua, 15), bgcolor=color.new(color.aqua, 87), text="BUYER ABSORPTION", text_color=color.aqua, text_size=size.tiny)
 
if showZones and sellSignal
    if not na(bearZone)
        box.delete(bearZone)
    bearZone := box.new(left=bar_index, top=high, right=bar_index + zoneExtension, bottom=math.min(open, close), border_color=color.new(color.red, 15), bgcolor=color.new(color.red, 87), text="SELLER ABSORPTION", text_color=color.red, text_size=size.tiny)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 07. BUY / SELL SIGNALS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
plotshape(showSignals and buySignal, title="BUY Absorption", style=shape.labelup, location=location.belowbar, color=color.rgb(0, 150, 120), text="BUY", textcolor=color.white, size=size.small)
 
plotshape(showSignals and sellSignal, title="SELL Absorption", style=shape.labeldown, location=location.abovebar, color=color.rgb(200, 55, 65), text="SELL", textcolor=color.white, size=size.small)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 08. RADAR DASHBOARD
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
var table radar = table.new(position.top_right, 2, 7, border_width=1, frame_color=color.new(color.gray, 50))
 
var string lastEvent = "WAITING"
 
if buySignal
    lastEvent := "BUYER ABSORPTION"
 
if sellSignal
    lastEvent := "SELLER ABSORPTION"
 
volumeStatus = volumeSpike ? "HIGH VOLUME" : "NORMAL"
volumeColor = volumeSpike ? color.new(color.orange, 30) : color.new(color.gray, 65)
 
pressureStatus = bullAbsorption ? "BUY PRESSURE" : bearAbsorption ? "SELL PRESSURE" : "NEUTRAL"
 
pressureColor = bullAbsorption ? color.new(color.green, 40) : bearAbsorption ? color.new(color.red, 40) : color.new(color.gray, 65)
 
trendStatus = close > ema ? "BULLISH" : close < ema ? "BEARISH" : "NEUTRAL"
 
if barstate.islast and showDashboard
    table.cell(radar, 0, 0, "THOMAS RADAR", bgcolor=color.rgb(20, 30, 48), text_color=color.white)
    table.cell(radar, 1, 0, "PRO", bgcolor=color.rgb(20, 30, 48), text_color=color.aqua)
 
    table.cell(radar, 0, 1, "Volume", bgcolor=color.new(color.gray, 80), text_color=color.white)
    table.cell(radar, 1, 1, volumeStatus, bgcolor=volumeColor, text_color=color.white)
 
    table.cell(radar, 0, 2, "Buy Pressure", bgcolor=color.new(color.gray, 80), text_color=color.white)
    table.cell(radar, 1, 2, bullAbsorption ? "DETECTED" : "NOT DETECTED", bgcolor=bullAbsorption ? color.new(color.green, 40) : color.new(color.gray, 65), text_color=color.white)
 
    table.cell(radar, 0, 3, "Sell Pressure", bgcolor=color.new(color.gray, 80), text_color=color.white)
    table.cell(radar, 1, 3, bearAbsorption ? "DETECTED" : "NOT DETECTED", bgcolor=bearAbsorption ? color.new(color.red, 40) : color.new(color.gray, 65), text_color=color.white)
 
    table.cell(radar, 0, 4, "Pressure", bgcolor=color.new(color.gray, 80), text_color=color.white)
    table.cell(radar, 1, 4, pressureStatus, bgcolor=pressureColor, text_color=color.white)
 
    table.cell(radar, 0, 5, "EMA Trend", bgcolor=color.new(color.gray, 80), text_color=color.white)
    table.cell(radar, 1, 5, trendStatus, bgcolor=close > ema ? color.new(color.green, 50) : color.new(color.red, 50), text_color=color.white)
 
    table.cell(radar, 0, 6, "Last Event", bgcolor=color.rgb(20, 30, 48), text_color=color.white)
    table.cell(radar, 1, 6, lastEvent, bgcolor=color.new(color.blue, 60), text_color=color.white)
 
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
// 09. ALERTS
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
alertcondition(buySignal, title="Thomas Buyer Absorption", message="Buyer absorption confirmed on candle close.")
alertcondition(sellSignal, title="Thomas Seller Absorption", message="Seller absorption confirmed on candle close.")
alertcondition(bullSweep and barstate.isconfirmed, title="Thomas Bullish Sweep", message="Bullish liquidity sweep detected.")
alertcondition(bearSweep and barstate.isconfirmed, title="Thomas Bearish Sweep", message="Bearish liquidity sweep detected.")
alertcondition(volumeSpike and barstate.isconfirmed, title="Thomas Volume Spike", message="Volume spike detected.")
 
 //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 // 10. THOMAS AUTO TARGET SYSTEM
 //━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 
groupTargets = "Auto Targets"
 
showTargets = input.bool(true, "Show Auto Targets", group=groupTargets)
targetATR = input.float(1.5, "Stop Loss ATR Multiplier", minval=0.2, step=0.1, group=groupTargets)
targetRR1 = input.float(1.0, "TP1 Risk Reward", minval=0.5, step=0.5, group=groupTargets)
targetRR2 = input.float(2.0, "TP2 Risk Reward", minval=1.0, step=0.5, group=groupTargets)
targetRR3 = input.float(3.0, "TP3 Risk Reward", minval=1.5, step=0.5, group=groupTargets)
targetExtension = input.int(20, "Target Line Extension", minval=5, maxval=200, group=groupTargets)
 
var line autoEntryLine = na
var line autoSLLine = na
var line autoTP1Line = na
var line autoTP2Line = na
var line autoTP3Line = na
 
var label autoEntryLabel = na
var label autoSLLabel = na
var label autoTP1Label = na
var label autoTP2Label = na
var label autoTP3Label = na
 
var float autoEntry = na
var float autoSL = na
var float autoTP1 = na
var float autoTP2 = na
var float autoTP3 = na
 
if buySignal or sellSignal
    if not na(autoEntryLine)
        line.delete(autoEntryLine)
        line.delete(autoSLLine)
        line.delete(autoTP1Line)
        line.delete(autoTP2Line)
        line.delete(autoTP3Line)
 
        label.delete(autoEntryLabel)
        label.delete(autoSLLabel)
        label.delete(autoTP1Label)
        label.delete(autoTP2Label)
        label.delete(autoTP3Label)
 
    autoEntry := close
    riskDistance = math.max(atr * targetATR, syminfo.mintick)
 
    if buySignal
        autoSL := autoEntry - riskDistance
        autoTP1 := autoEntry + riskDistance * targetRR1
        autoTP2 := autoEntry + riskDistance * targetRR2
        autoTP3 := autoEntry + riskDistance * targetRR3
    else
        autoSL := autoEntry + riskDistance
        autoTP1 := autoEntry - riskDistance * targetRR1
        autoTP2 := autoEntry - riskDistance * targetRR2
        autoTP3 := autoEntry - riskDistance * targetRR3
 
    if showTargets
        autoEntryLine := line.new(bar_index, autoEntry, bar_index + targetExtension, autoEntry, extend=extend.right, color=color.blue, width=2)
        autoSLLine := line.new(bar_index, autoSL, bar_index + targetExtension, autoSL, extend=extend.right, color=color.red, width=2)
        autoTP1Line := line.new(bar_index, autoTP1, bar_index + targetExtension, autoTP1, extend=extend.right, color=color.lime, width=1)
        autoTP2Line := line.new(bar_index, autoTP2, bar_index + targetExtension, autoTP2, extend=extend.right, color=color.lime, width=1)
        autoTP3Line := line.new(bar_index, autoTP3, bar_index + targetExtension, autoTP3, extend=extend.right, color=color.green, width=2)
 
        autoEntryLabel := label.new(bar_index + targetExtension, autoEntry, "ENTRY " + str.tostring(autoEntry, format.mintick), style=label.style_label_left, color=color.blue, textcolor=color.white, size=size.small)
        autoSLLabel := label.new(bar_index + targetExtension, autoSL, "SL " + str.tostring(autoSL, format.mintick), style=label.style_label_left, color=color.red, textcolor=color.white, size=size.small)
        autoTP1Label := label.new(bar_index + targetExtension, autoTP1, "TP1 " + str.tostring(autoTP1, format.mintick), style=label.style_label_left, color=color.green, textcolor=color.white, size=size.small)
        autoTP2Label := label.new(bar_index + targetExtension, autoTP2, "TP2 " + str.tostring(autoTP2, format.mintick), style=label.style_label_left, color=color.green, textcolor=color.white, size=size.small)
        autoTP3Label := label.new(bar_index + targetExtension, autoTP3, "TP3 " + str.tostring(autoTP3, format.mintick), style=label.style_label_left, color=color.green, textcolor=color.white, size=size.small)

← 返回列表