PROTECTED SOURCE SCRIPT

Custom Time Frame Background with High-Low

20
🔍 Explanation:
Custom Time Frame Calculation: Converted to minutes, then used with time("xxx") to detect new periods.

New Period Detection: Using ta.change(time("xxx")).

Track High/Low: Variables (var) keep high/low values and reset on each new period.

Background Plotting: Uses bgcolor only during defined custom time frames.

Plot High/Low Lines: Visual representation of range boundaries for each time frame.

✅ Example Use:
Set Custom Hours = 4 → The chart background alternates color every 4 hours.

Displays background and high/low range lines for each custom time period.

If you would like to extend the script further—such as showing only during specific times of day (e.g., market open/close from 9:00 to 16:00)—I can help with that as well. Just let me know.


To make your Pine Script display the background only during custom time frames and also show the high and low values of that period, we need to:

Track the high (high) and low (low) of each custom time frame

Highlight the background only during that specific period

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。