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.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.