I created a Watchlist column to sort thru symbols faster,
for current number of closes within 1 range to the last close. Yet still wrong counts but closer.
Only the total # of closes near the last close (can be edited to last price), with a small buffer range of .0035 higher or lower.
(the very tiny range threshold can be edited,)
I asked both ChatGpt & Bard, & very much the same result, both were fails, so I actually wrote this piecemeal from the chart version.
My piecemeal code... still wrong counts but closer.
# Define a Range around LastClose !!
input lookbackPeriod = 10; #?!! I used to a long time ago but I'm too busy,
input threshold = 0.0035; # ranges + or - percent
def lastClose = if !isnan(close[-1]) then close[-1] else 0;
def increment = lastClose * threshold;
def range1Low = lastClose - increment;
def range1High = lastClose + increment;
def range = range1High - range1Low;
def candleCount = sum(if !isnan(close) and close >= range1Low and close <= range1High then 1 else 0, lookbackPeriod);
# Plot the result in the watchlist column
plot result = candleCount;
------------------------------------------------
Someday maybe adding an RSI:
Rsi w/3 different font colors upon conditions:
1) if the total #of bars near the last close were <6 with a low RSI (30% or less), "green font (buy)"
2) and if the total #of bars near the last close were >15 or <6, with a high RSI (60% or more). "red font (sell)"
Where a low bar count w/a low rsi would indicate an entry,
and a high bar count or extremely low bar count w/a high rsi would indicate an exit.
On some charts it looks like nice entry & exit.
My pretty font colored RSI for a Watchlist Column:
input VLow =35;
input Low = 42;
input High = 58;
input VHigh = 68;
plot RSI = Round(RSI(),0);
RSI.AssignValueColor(
if RSI < VLow then Color.GREEN
else if RSI >= VLow and RSI < Low then CreateColor(97, 155, 22)
else if RSI >= Low and RSI < High then CreateColor(209, 229, 182)
else if RSI >= High and RSI < VHigh then CreateColor(178, 109, 218)
else CreateColor(208, 43, 98)
);
----------------------------