OPEN-SOURCE SCRIPT
Box Theory

Box Theory – Description
This indicator is based on the popular “Box Theory” concept, where the previous session’s High–Low range acts as the most important structure for the next session.
Traders use this because the market often reacts to the same areas where liquidity, orders, and imbalances were created in the prior session.
At every new session open, the indicator automatically records:
Previous High
Previous Low
Middle (50% level)
These three levels form a box, which becomes your roadmap for the new session.
This method is widely used because it highlights where most reversals, sweeps, and reactions occur—without needing any extra indicators.
How the Zones Are Calculated
Previous High
The highest price of the last session.
This forms the top edge, which acts as resistance and the basis for the Sell Zone.
Previous Low
The lowest price of the last session.
This forms the bottom edge, acting as support and the basis for the Buy Zone.
Middle Line (50% Level)
The exact midpoint between High and Low.
This is the fair-value zone, where price often consolidates and becomes directionless.
No signals are triggered near the middle, because trades taken here historically have low accuracy.
Buy Zone (Green Area)
The lower part of the box.
Price often reacts here because this area held buyers in the previous session.
When price enters this green zone inside the box, the indicator can show a Buy Zone label.
Sell Zone (Red Area)
The upper part of the box.
Price commonly rejects here because this area acted as resistance previously.
When price enters this red zone inside the box, the indicator can show a Sell Zone label.
How Zone Size Is Set (Sensitivity %)
You can adjust how big the Buy/Sell zones are using the Sensitivity (%) input.
Lower % → Smaller zones → More precise signals
Higher % → Larger zones → Signals appear earlier and from farther away
Formula:
Zone Size = (Previous High − Previous Low) × (Sensitivity % ÷ 100)
This lets you customize how tight or how early your signals appear.
Inside-Box Only Logic
The indicator only works inside the previous session’s range.
If price breaks above the previous High → No sell signal
If price breaks below the previous Low → No buy signal
This avoids false signals during breakouts or trending markets.
Alerts
The indicator includes two alerts:
Buy Zone Alert → Triggers when price enters the Buy Zone
Sell Zone Alert → Triggers when price enters the Sell Zone
Just enable them in TradingView’s alert panel.
This indicator is based on the popular “Box Theory” concept, where the previous session’s High–Low range acts as the most important structure for the next session.
Traders use this because the market often reacts to the same areas where liquidity, orders, and imbalances were created in the prior session.
At every new session open, the indicator automatically records:
Previous High
Previous Low
Middle (50% level)
These three levels form a box, which becomes your roadmap for the new session.
This method is widely used because it highlights where most reversals, sweeps, and reactions occur—without needing any extra indicators.
How the Zones Are Calculated
Previous High
The highest price of the last session.
This forms the top edge, which acts as resistance and the basis for the Sell Zone.
Previous Low
The lowest price of the last session.
This forms the bottom edge, acting as support and the basis for the Buy Zone.
Middle Line (50% Level)
The exact midpoint between High and Low.
This is the fair-value zone, where price often consolidates and becomes directionless.
No signals are triggered near the middle, because trades taken here historically have low accuracy.
Buy Zone (Green Area)
The lower part of the box.
Price often reacts here because this area held buyers in the previous session.
When price enters this green zone inside the box, the indicator can show a Buy Zone label.
Sell Zone (Red Area)
The upper part of the box.
Price commonly rejects here because this area acted as resistance previously.
When price enters this red zone inside the box, the indicator can show a Sell Zone label.
How Zone Size Is Set (Sensitivity %)
You can adjust how big the Buy/Sell zones are using the Sensitivity (%) input.
Lower % → Smaller zones → More precise signals
Higher % → Larger zones → Signals appear earlier and from farther away
Formula:
Zone Size = (Previous High − Previous Low) × (Sensitivity % ÷ 100)
This lets you customize how tight or how early your signals appear.
Inside-Box Only Logic
The indicator only works inside the previous session’s range.
If price breaks above the previous High → No sell signal
If price breaks below the previous Low → No buy signal
This avoids false signals during breakouts or trending markets.
Alerts
The indicator includes two alerts:
Buy Zone Alert → Triggers when price enters the Buy Zone
Sell Zone Alert → Triggers when price enters the Sell Zone
Just enable them in TradingView’s alert panel.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.