you mentioned scan and display words, so i'm not sure what you want.

i made this up chart study.

this will look for x bars in a row, at the same high, or same low price, and draw arrows, on the main chart.

can choose how many bars are to be near the same price.

it checks if adjacent bars have a price within x % . the default is 0.02%. set to 0 if you want prices exactly the same.

can choose to also look for a pivot. it just looks at the bars before the same bars, so i'm calling this condition a half pivot. (it doesn't look at the bars after the same bars).

can show dots for the same price conditions and half pivots.

Code:

```
# same_price_for_x_bars_0
# https://usethinkscript.com/threads/scan-that-would-show-when-there-has-been-3-of-the-same-price-as-a-high-low.13246/
# scan that would show when there has been 3 of the same price as a high / low
#-----------------------------------
def na = double.nan;
def bn = barnumber();
input min_qty_of_same_price = 3;
def minq = min_qty_of_same_price;
# matching price tolerance percent
input match_tol_percent = 0.02;
def ishimatch_per = absvalue(high[1] - high) <= (high * (match_tol_percent/100));
def islomatch_per = absvalue(low[1] - low) <= (low * (match_tol_percent/100));
# were there x bars in a row, that had a price within y %?
def hix = if bn <= minq then 0 else (sum(ishimatch_per, minq-1) == (minq-1));
def lox = if bn <= minq then 0 else (sum(islomatch_per, minq-1) == (minq-1));
input pivot_len = 5;
# the previous bars form half a pivot
input check_for_half_pivot = yes;
input arrows = yes;
input dots_same_price = yes;
def vert1 = 0.003;
plot zhix = if (dots_same_price and hix) then (high * (1 + (2 * vert1))) else na;
zhix.SetPaintingStrategy(PaintingStrategy.POINTS);
zhix.SetDefaultColor(Color.yellow);
zhix.setlineweight(3);
zhix.hidebubble();
plot zlox = if (dots_same_price and lox) then (low * (1 - (2 * vert1))) else na;
zlox.SetPaintingStrategy(PaintingStrategy.POINTS);
zlox.SetDefaultColor(Color.blue);
zlox.setlineweight(3);
zlox.hidebubble();
#---------------------------
# half a pivot check, look at prev x bars
# check if prev highs were lower, or prev lows were higher
#input check_for_pivot = yes;
#input pivot_len = 5;
def hipiv = if !check_for_half_pivot then 1 else (high[minq-1] > highest(high[minq], pivot_len));
def lopiv = if !check_for_half_pivot then 1 else (low[minq-1] < lowest(low[minq], pivot_len));
input dots_pivot = yes;
plot zhipiv = if (dots_pivot and hipiv) then (high * (1 + (3 * vert1))) else na;
zhipiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zhipiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zhipiv.SetDefaultColor(Color.red);
zhipiv.setlineweight(3);
zhipiv.hidebubble();
plot zlopiv = if (dots_pivot and lopiv) then (low * (1 - (3 * vert1))) else na;
zlopiv.SetPaintingStrategy(PaintingStrategy.POINTS);
#zlopiv.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
zlopiv.SetDefaultColor(Color.green);
zlopiv.setlineweight(3);
zlopiv.hidebubble();
#-----------------------------------
def downx = (hix and hipiv);
def upx = (lox and lopiv);
#input arrows = yes;
plot zdownx = if (arrows and downx) then (high * (1 + (0.5 * vert1))) else na;
zdownx.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
#zdownx.SetPaintingStrategy(PaintingStrategy.POINTS);
zdownx.SetDefaultColor(Color.red);
zdownx.setlineweight(3);
zdownx.hidebubble();
plot zupx = if (arrows and upx) then (low * (1 - (0.5 * vert1))) else na;
zupx.SetPaintingStrategy(PaintingStrategy.ARROW_up);
#zupx.SetPaintingStrategy(PaintingStrategy.POINTS);
zupx.SetDefaultColor(Color.green);
zupx.setlineweight(3);
zupx.hidebubble();
#
```

SWN 1min