PROTECTED SOURCE SCRIPT
Mark 4H Candle Span

This TradingView indicator, called "Mark 4H Candle Span", serves to **visually highlight alternating 4-hour time blocks** directly on the price chart.It does this by coloring the background of the chart for one 4-hour period and leaving the next 4-hour period uncolored, creating a pattern of vertical stripes.---### How It WorksThe code operates in two main steps:1. **Calculation of the 4-Hour Block**:The line `session_id = math.floor(time("1") / (1000 * 60 * 60 * 4))` calculates a unique identification (ID) number for each 4-hour block.* `time("1")`: Gets the current time (in milliseconds).* `(1000 * 60 * 60 * 4)`: Is the total number of milliseconds in 4 hours.* By dividing the time by the 4-hour interval and rounding down with `math.floor`, the script assigns the same `session_id` to all the candles within the same 4-hour block.2. **Background Coloring**:The line `bgcolor(session_id % 2 == 0 ? color.new(color.blue, 85) : na)` decides whether to color the background.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – 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.
Protected script
This script is published as closed-source. However, you can use it freely and without any limitations – 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.