OPEN-SOURCE SCRIPT
업데이트됨

Higher Timeframe Box & Divider - All Candles [GoldnHunt]

2 012
The Higher Timeframe Box & Divider – All Candles indicator visually maps higher timeframe candles onto lower timeframe charts.
It highlights the open and close range of each higher timeframe candle as a box, along with a vertical divider marking the start of each new period.
This helps traders clearly see higher timeframe structure and momentum flow without switching charts.

Features:
  • Draws a box showing only the body (open to close) of each higher timeframe candle.
  • Uses candle color to represent bullish and bearish momentum.
  • Adds a divider line for each new higher timeframe candle.
  • Works across all symbols and timeframes.
  • Lightweight and optimized for performance.


Use case:
Perfect for traders using multi-timeframe (MTF) analysis who want to visualize higher timeframe candle progression while observing lower timeframe price action.
릴리즈 노트
The Higher Timeframe Box & Divider [GoldnHunt] is a technical analysis tool designed to improve multi-timeframe (MTF) awareness without forcing the trader to switch charts.

It accomplishes this by overlaying the price action of higher timeframes (HTF) directly onto your current lower timeframe chart. The script visualizes HTF candles as dynamic boxes (representing the body/range) and marks the boundaries of time cycles with vertical dividers. It is particularly useful for traders who want to see "the big picture" (e.g., 1-hour or 4-hour candle developments) while executing trades on 1-minute or 5-minute charts.

Core Functionality
  • Contextual Boxes: Draws boxes that expand in real-time as the HTF candle develops.
  • Visual Dividers: Vertical lines mark exactly when a new HTF candle begins.
  • Smart Timeframe Logic: Automatically detects the next logical higher timeframe (e.g., if you are on 15m, it suggests 1h; if you are on Daily, it suggests Weekly).
  • Real-time Alignment: Includes a "Next Candle" projection line to show exactly when the current HTF period will end.


What’s Changed (v1 vs. v2)
The second version represents a major leap in both efficiency and functionality. Here are the key upgrades:

1. Multi-Level Visualization (The Biggest Feature)
Old: Only supported one higher timeframe (1 HTF).

New: Introduces three distinct modes:

1 HTF: Traditional view.

2 HTF: Skips the immediate higher timeframe to show a much larger cycle (e.g., showing 4H boxes on a 15m chart).

1HTF + 2HTF: A nested view that shows both levels simultaneously, allowing you to see how smaller HTF candles fit inside larger ones.

2. Performance & Optimization
Consolidated Security Calls: In Pine Script, request.security is "expensive." The new version uses tuple calls [s_time, s_time_confirmed, ...] to fetch multiple data points in a single request, significantly reducing the load on TradingView’s servers.

Cached Calculations: HTF strings and durations are now stored in var variables and only recalculated if you change the settings, preventing unnecessary calculations on every single bar.

Memory Management: Logic was added to ensure objects (boxes/lines) are only updated when strictly necessary.

3. Accuracy & Logic Fixes
Lookahead Management: You fixed a common "repainting" issue. The script now uses lookahead_on only for time detection (to ensure dividers line up perfectly with the start of the bar) but uses lookahead_off for price data to ensure your backtesting remains honest and valid.

State Persistence: By using var for candle highs, lows, and opens, the script now accurately tracks the HTF price movement throughout the duration of the bar, even if the lower timeframe data fluctuates.

4. Code Quality & Maintenance
Warning Suppression: Moved ta.change() outside of conditional expressions. This is a best practice in Pine Script v6 to ensure the internal "history" of the function is updated on every bar, preventing calculation errors.

Modular Design: The use of helper functions like get_line_style() makes the code much cleaner and easier to read.

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.