OPEN-SOURCE SCRIPT
9th and 5th Candle Pattern - High/Low Break Logic

I implemented a Pine-Script (TradingView, v5) indicator that looks at a 9-candle window and marks the two patterns you described, with a clear, tweakable interpretation so it’s useful immediately on your chart.
My interpretation (keeps things deterministic & chart-friendly):
We treat the current bar as the 9th candle and look back 8 bars (so the 5th candle is close[4] / open[4]).
Pattern A (5th green):
If candle #5 is bullish (close[4] > open[4]) AND none of the next 4 candles (6,7,8,9 → offsets [3,2,1,0]) have a low below candle #5 low (i.e. that low was not broken), AND the 6th candle (offset 3) made a higher high than candle #5, then the script places a label/arrow on the 6th candle saying a bullish continuation / "up possible" signal.
Pattern B (5th red):
If candle #5 is bearish (close[4] < open[4]) AND within the next 4 candles the high moved above candle #5 high (i.e. price attempted to reverse), then the script places a label/arrow on the 9th (current) candle indicating a possible high / reversal by the 9th.
You can tweak the number of look-ahead candles or the strictness easily in the code comments.
My interpretation (keeps things deterministic & chart-friendly):
We treat the current bar as the 9th candle and look back 8 bars (so the 5th candle is close[4] / open[4]).
Pattern A (5th green):
If candle #5 is bullish (close[4] > open[4]) AND none of the next 4 candles (6,7,8,9 → offsets [3,2,1,0]) have a low below candle #5 low (i.e. that low was not broken), AND the 6th candle (offset 3) made a higher high than candle #5, then the script places a label/arrow on the 6th candle saying a bullish continuation / "up possible" signal.
Pattern B (5th red):
If candle #5 is bearish (close[4] < open[4]) AND within the next 4 candles the high moved above candle #5 high (i.e. price attempted to reverse), then the script places a label/arrow on the 9th (current) candle indicating a possible high / reversal by the 9th.
You can tweak the number of look-ahead candles or the strictness easily in the code comments.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.