I don't believe this is the problem, Nb & Ns are counting correctly
I think the problem is in the code in the below image, since H1 and L1 values are updated with each candle close, the code checks only after "L1 and H1" that match the criteria, instead of checking for 10 candles after it.