OPEN-SOURCE SCRIPT

Shadow Detector

14
//version=5
indicator("Shadow Detector", overlay=true)

// === Inputs ===
// ---- Upper Wick Controls ----
enableMinUpperWick = input.bool(true, "", group="Long Upper Wick Settings",inline = 'A')
minUpperWickPerc = input.float(0.4, "Min Upper Wick %", step=0.01, group="Long Upper Wick Settings",inline = 'A')

enableMaxLowerWick = input.bool(true, "", group="Long Upper Wick Settings",inline = 'B')
maxLowerWickPerc = input.float(0.5, "Max Lower Wick %", step=0.01, group="Long Upper Wick Settings",inline = 'B')

enableMaxBodyUpper = input.bool(true, " ", group="Long Upper Wick Settings",inline = 'C')
maxBodyPercUpper = input.float(100.0, "Max Body % (Upper Wick)", step=0.01, group="Long Upper Wick Settings",inline = 'C')

// ---- Lower Wick Controls ----
enableMinLowerWick = input.bool(true, "", group="Long Lower Wick Settings",inline = 'd')
minLowerWickPerc = input.float(0.4, "Min Lower Wick %", step=0.01, group="Long Lower Wick Settings",inline = 'd')

enableMaxUpperWick = input.bool(true, "", group="Long Lower Wick Settings",inline = 'e')
maxUpperWickPerc = input.float(0.5, "Max Upper Wick %", step=0.01, group="Long Lower Wick Settings",inline = 'e')

enableMaxBodyLower = input.bool(true, "", group="Long Lower Wick Settings",inline = 'f')
maxBodyPercLower = input.float(100.0, "Max Body % (Lower Wick)", step=0.01, group="Long Lower Wick Settings",inline = 'f')

// === Calculations ===
bodySize = math.abs(close - open)
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low

// Reference price
refPrice = close // you can change to (high+low)/2 or open if preferred

// Thresholds for Upper Wick Condition
minUpperWickPoints = refPrice * (minUpperWickPerc / 100)
maxLowerWickPoints = refPrice * (maxLowerWickPerc / 100)
maxBodyPointsUpper = refPrice * (maxBodyPercUpper / 100)

// Thresholds for Lower Wick Condition
minLowerWickPoints = refPrice * (minLowerWickPerc / 100)
maxUpperWickPoints = refPrice * (maxUpperWickPerc / 100)
maxBodyPointsLower = refPrice * (maxBodyPercLower / 100)

// === Conditions with Enable/Disable Logic ===
// Long Upper Shadow conditions (only check enabled conditions)
upperCondition1 = enableMaxBodyUpper ? bodySize <= maxBodyPointsUpper : true
upperCondition2 = enableMinUpperWick ? upperWick >= minUpperWickPoints : true
upperCondition3 = enableMaxLowerWick ? lowerWick <= maxLowerWickPoints : true
longUpper = upperCondition1 and upperCondition2 and upperCondition3

// Long Lower Shadow conditions (only check enabled conditions)
lowerCondition1 = enableMaxBodyLower ? bodySize <= maxBodyPointsLower : true
lowerCondition2 = enableMinLowerWick ? lowerWick >= minLowerWickPoints : true
lowerCondition3 = enableMaxUpperWick ? upperWick <= maxUpperWickPoints : true
longLower = lowerCondition1 and lowerCondition2 and lowerCondition3

// === Plot Shapes ===
plotshape(longUpper, title="Long Upper Shadow", style=shape.triangledown, color=color.red, size=size.small, location=location.abovebar)
plotshape(longLower, title="Long Lower Shadow", style=shape.triangleup, color=color.green, size=size.small, location=location.belowbar)

// === Alerts ===
alertcondition(longUpper, title="Long Upper Shadow", message="Upper shadow conditions met")
alertcondition(longLower, title="Long Lower Shadow", message="Lower shadow conditions met")

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.