OPEN-SOURCE SCRIPT
Inside 4+ Candles Box (Entry + Target + SMA Stop Logic)

🔍 What This Script Does
This indicator detects price compression areas using 4 or more consecutive inside candles, then draws a breakout box to visually highlight the range.
Once price closes above the box, a long entry marker is plotted, along with:
🎯 Target line at 1x box size above the breakout.
❌ Stop-loss at the box low or at a dynamic SMA-based level if the box is too large.
🧠 Why It’s Unique
This script combines inside bar compression, breakout logic, risk control, and visual clarity — all in one tool.
It also cancels the setup entirely if price closes below the box low before breakout, avoiding late or false entries.
⚙️ Customizable Settings
Minimum inside candles (default = 4)
SMA length (used as stop if box is large)
Box size % threshold to activate smart stop
Entry, Target, and Stop marker colors
📌 Notes
For long setups only (no short signals).
Use on any asset or timeframe (ideal on 4H/1D).
This is not financial advice. Use with proper risk management.
Backtest thoroughly before live use.
Built with ❤️ by [abusuhil] using Pine Script v6.
🇸🇦 وصف مختصر باللغة العربية:
هذا المؤشر يكتشف مناطق تماسك السعر من خلال 4 شموع داخلية أو أكثر، ثم يرسم مربعًا يحدد منطقة الاختراق المحتملة.
عند الإغلاق أعلى المربع، يتم عرض إشارة دخول وسطر هدف بنسبة 100% من حجم المربع.
كما يتم احتساب وقف الخسارة تلقائيًا إما عند قاع المربع أو عند متوسط متحرك ذكي (SMA) إذا كان حجم المربع كبيرًا.
الميزة الإضافية: إذا تم كسر قاع المربع قبل الاختراق، يتم إلغاء الصفقة تلقائيًا لتجنب الدخول المتأخر.
🧪 للاستفادة التعليمية والتحليل فقط. لا يُعتبر توصية مالية.
This indicator detects price compression areas using 4 or more consecutive inside candles, then draws a breakout box to visually highlight the range.
Once price closes above the box, a long entry marker is plotted, along with:
🎯 Target line at 1x box size above the breakout.
❌ Stop-loss at the box low or at a dynamic SMA-based level if the box is too large.
🧠 Why It’s Unique
This script combines inside bar compression, breakout logic, risk control, and visual clarity — all in one tool.
It also cancels the setup entirely if price closes below the box low before breakout, avoiding late or false entries.
⚙️ Customizable Settings
Minimum inside candles (default = 4)
SMA length (used as stop if box is large)
Box size % threshold to activate smart stop
Entry, Target, and Stop marker colors
📌 Notes
For long setups only (no short signals).
Use on any asset or timeframe (ideal on 4H/1D).
This is not financial advice. Use with proper risk management.
Backtest thoroughly before live use.
Built with ❤️ by [abusuhil] using Pine Script v6.
🇸🇦 وصف مختصر باللغة العربية:
هذا المؤشر يكتشف مناطق تماسك السعر من خلال 4 شموع داخلية أو أكثر، ثم يرسم مربعًا يحدد منطقة الاختراق المحتملة.
عند الإغلاق أعلى المربع، يتم عرض إشارة دخول وسطر هدف بنسبة 100% من حجم المربع.
كما يتم احتساب وقف الخسارة تلقائيًا إما عند قاع المربع أو عند متوسط متحرك ذكي (SMA) إذا كان حجم المربع كبيرًا.
الميزة الإضافية: إذا تم كسر قاع المربع قبل الاختراق، يتم إلغاء الصفقة تلقائيًا لتجنب الدخول المتأخر.
🧪 للاستفادة التعليمية والتحليل فقط. لا يُعتبر توصية مالية.
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.