OPEN-SOURCE SCRIPT
Updated Custom Time Range Boxes + Fibs + Extension

This script draws two customizable time-range boxes per day, helping traders visualize key market sessions or activity windows. Each box is defined by start and end times that can be adjusted in the settings. You can also choose a custom color and extend the visual width of the box independently from the actual session time. Within each box, the indicator plots three Fibonacci levels: 0.3, 0.5, and 0.7. These levels are useful for identifying potential support, resistance, or retracement zones inside the session range. The script supports two separate time blocks, allowing you to track sessions like the New York Open and Power Hour simultaneously. All lines and boxes are drawn using bar_index for precision and control. The levels and box colors match for visual consistency. Perfect for intraday traders who want to track price behavior around key times. Clean, minimal, and performance-friendly — this tool adds clarity to your session-based strategy.
Release Notes
Update Announcement: Custom Time Range Boxes + Fibs + ExtensionWe are thrilled to release a significantly improved version of the Custom Time Range Boxes + Fibs + Extension Pine Script indicator! This update addresses critical issues in the original code, enhances compatibility with Pine Script version 5, and ensures a more robust and reliable experience for traders. Below, we outline the key improvements and provide the updated code for you to use and share.
What's New and Improved?
The original script, while functional, encountered several errors that limited its usability, including issues with nested arrays, incorrect timeframe identifiers, and restricted request.security calls. This updated version resolves these problems and introduces the following enhancements:
Resolved Nested Array Error:
The original code used unsupported nested arrays (array<array<line>>) to store Fibonacci lines, causing compilation errors. The updated version replaces this with a single array<line> and tracks line counts using an additional array<int>, ensuring compatibility with Pine Script's limitations while maintaining the ability to manage multiple Fibonacci lines per box.
Fixed Timeframe Identifier:
The original script incorrectly used timeframe.is_intraday, leading to an "Undeclared identifier" error. This has been corrected to timeframe.isintraday, ensuring proper detection of intraday timeframes and seamless operation across different chart settings.
Enabled Dynamic Security Requests:
The original code placed request.security calls within conditional blocks, which violated Pine Script's restrictions and triggered errors. The updated version moves these calls outside conditionals and enables dynamic_requests=true in the indicator() function, allowing flexible data retrieval from the 1-hour timeframe without compromising functionality.
Preserved Core Functionality:
Despite these technical improvements, the core functionality remains intact: the indicator draws customizable time-based boxes with Fibonacci retracement levels (0.3, 0.5, 0.7) on the chart, supports two separate sessions, and extends boxes for a user-defined number of candles. The update ensures that all features work as intended, with improved stability.
Enhanced Reliability:
By addressing these errors, the updated script is more robust, reducing the likelihood of runtime issues and making it suitable for public use. It now handles edge cases better, such as invalid time ranges, and provides clear error messages when configurations are incorrect.
Why This Version Is Better
Compared to the original code, this version is a leap forward in terms of reliability, compatibility, and user experience. The original script was hindered by compilation errors that prevented it from running correctly in many scenarios. The updated version not only fixes these issues but also ensures that the indicator performs consistently across different timeframes and configurations. Whether you're a trader looking to visualize key session ranges or a developer seeking a reliable base for further customization, this script is now ready for prime time.
Try It Out!
We invite you to test the updated Custom Time Range Boxes + Fibs + Extension indicator on TradingView. Customize the session times, box lengths, and colors to suit your trading strategy, and enjoy the seamless integration of Fibonacci levels for better market analysis. Feel free to share your feedback and suggestions for further improvements!
Below is the complete, updated Pine Script code for your use:
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.