OPEN-SOURCE SCRIPT
Discipline Box Trader — by chaitu50c

Discipline Box Trader — by chaitu50c is a rule-based price action tool built around alternating candle structures.
For each session, the indicator detects FIRST key alternating zone, marks it as a gray “Discipline Box”, and then tracks how price breaks and rotates through that zone with clear green/red segments.
The idea is simple:
The script continuously looks for alternating candle sequences:
Red → Green → Red → Green …
or
Green → Red → Green → Red …
When the sequence reaches your minimum required length (Min candles in alternate combo), it:
Finds the highest high and lowest low of that entire alternation combo.
Draws a gray rectangular box from the start of the combo to its end.
This gray region is named the “Discipline Box”.
After this Discipline Box is created:
Upside breakout → close > box high
Downside breakout → close < box low
For example if, Upside Breakout → Green Regime Segment
The gray box is visually closed at the previous bar.
A new green box segment starts from the breakout bar.
Box fill, border, and center line all turn green.
This green segment extends to the right until another breakout flips the regime.
There is a small visible gap between the gray box and the new coloured segment, clearly showing where the breakout actually occurred.
Within the same session, price may:
Break up → green segment.
Later break down through the same band → red segment.
Possibly flip again.
All of this happens inside the one original Discipline Box, giving a clean visual map of who is in control now without creating new zones.
Reset Mode
None
No automatic reset; box can persist across all data.
New Day
At each new trading day:
Current box and center line are closed.
All internal counters reset.
A completely fresh Discipline Box can form for the new day.
Gap Minutes
If time between candles exceeds Gap Threshold (minutes):
Treat this as a session break.
Close the current box and restart detection after the gap.
This ensures clarity and separation between sessions and prevents overlapping “old” structure from dominating new market conditions.
Trading Framework: 2 Trades per Discipline Box
⚠️ This is not financial advice. This is a structured usage idea to support discipline.
A suggested trading framework to pair with this indicator:
Trade 1 — First Breakout Trade
Wait for the first body-based breakout from the Discipline Box:
Upside breakout → consider a single long trade.
Downside breakout → consider a single short trade.
Use the box high, low, and midline as reference points for:
Stop placement, partial exits, or risk-reward zones.
Trade 2 — Opposite Regime Flip
If price later breaks the opposite side of the same box:
Consider exactly one more trade in the new direction (a failed breakout / reversal play).
Example: green regime first, later broken down into red → potential short trade.
After these maximum 2 trades per Discipline Box, you can:
Skip additional trades inside that session’s structure.
Wait patiently for the next session and next Discipline Box to form.
This hard rule helps avoid over-trading, revenge trades, and emotional interference — staying faithful to the “Discipline” theme.
The indicator has a built-in alert condition: Discipline Box Detected
Triggers Whenever a new gray Discipline Box is created (i.e., the first valid alternation zone for that session).
Practical Notes & Disclaimer
The indicator does not tell you when to buy or sell; it simply:
Marks a disciplined structure zone.
Shows live regime shifts (green/red).
Supports a clear “max 2 trades per box” framework.
Use on a demo first, adapt to your style, and always remember:
Your discipline matters more than the indicator.
For each session, the indicator detects FIRST key alternating zone, marks it as a gray “Discipline Box”, and then tracks how price breaks and rotates through that zone with clear green/red segments.
The idea is simple:
The script continuously looks for alternating candle sequences:
Red → Green → Red → Green …
or
Green → Red → Green → Red …
When the sequence reaches your minimum required length (Min candles in alternate combo), it:
Finds the highest high and lowest low of that entire alternation combo.
Draws a gray rectangular box from the start of the combo to its end.
This gray region is named the “Discipline Box”.
After this Discipline Box is created:
Upside breakout → close > box high
Downside breakout → close < box low
For example if, Upside Breakout → Green Regime Segment
The gray box is visually closed at the previous bar.
A new green box segment starts from the breakout bar.
Box fill, border, and center line all turn green.
This green segment extends to the right until another breakout flips the regime.
There is a small visible gap between the gray box and the new coloured segment, clearly showing where the breakout actually occurred.
Within the same session, price may:
Break up → green segment.
Later break down through the same band → red segment.
Possibly flip again.
All of this happens inside the one original Discipline Box, giving a clean visual map of who is in control now without creating new zones.
Reset Mode
None
No automatic reset; box can persist across all data.
New Day
At each new trading day:
Current box and center line are closed.
All internal counters reset.
A completely fresh Discipline Box can form for the new day.
Gap Minutes
If time between candles exceeds Gap Threshold (minutes):
Treat this as a session break.
Close the current box and restart detection after the gap.
This ensures clarity and separation between sessions and prevents overlapping “old” structure from dominating new market conditions.
Trading Framework: 2 Trades per Discipline Box
⚠️ This is not financial advice. This is a structured usage idea to support discipline.
A suggested trading framework to pair with this indicator:
Trade 1 — First Breakout Trade
Wait for the first body-based breakout from the Discipline Box:
Upside breakout → consider a single long trade.
Downside breakout → consider a single short trade.
Use the box high, low, and midline as reference points for:
Stop placement, partial exits, or risk-reward zones.
Trade 2 — Opposite Regime Flip
If price later breaks the opposite side of the same box:
Consider exactly one more trade in the new direction (a failed breakout / reversal play).
Example: green regime first, later broken down into red → potential short trade.
After these maximum 2 trades per Discipline Box, you can:
Skip additional trades inside that session’s structure.
Wait patiently for the next session and next Discipline Box to form.
This hard rule helps avoid over-trading, revenge trades, and emotional interference — staying faithful to the “Discipline” theme.
The indicator has a built-in alert condition: Discipline Box Detected
Triggers Whenever a new gray Discipline Box is created (i.e., the first valid alternation zone for that session).
Practical Notes & Disclaimer
The indicator does not tell you when to buy or sell; it simply:
Marks a disciplined structure zone.
Shows live regime shifts (green/red).
Supports a clear “max 2 trades per box” framework.
Use on a demo first, adapt to your style, and always remember:
Your discipline matters more than the indicator.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.