// ------------------------------------
// INPUTS
// ------------------------------------
// Price and Volume constraints
priceCap = 20
volCap = 1000000
volLength = 20 // Moving average period for volume
// Lookback period for the demand zone (Support)
lookback = 50
// Tolerance to define "touching" or "very close" (0.02 = 2%)
tolerance = 0.02
// ------------------------------------
// FILTERS CALCULATION
// ------------------------------------
// Calculate Average Volume
avgVol = Average[volLength](Volume)
// Conditions for Price and Volume
c1 = Close < priceCap
c2 = avgVol > volCap
// ------------------------------------
// DEMAND ZONE IDENTIFICATION
// ------------------------------------
supportLevel = Lowest[lookback](Low)[1]
// ------------------------------------
// PROXIMITY LOGIC
// ------------------------------------
// Upper limit and lower limit
zoneTop = supportLevel * (1 + tolerance)
zoneBot = supportLevel * (1 - tolerance)
c3 = Low <= zoneTop AND Close >= zoneBot
// ------------------------------------
SCREENER[c1 AND c2 AND c3] ((Close - supportLevel) / supportLevel * 100 AS "% Dist to Supp")