HTF Candles [EXCAVO]Higher Timeframe Candles in a Panel to the Right of the Chart
The HTF Candles indicator renders higher timeframe candles in a
dedicated panel to the right of all chart data. Each completed HTF candle
is drawn as a solid semi-transparent box (body) with color-matched wick
lines. The currently forming candle uses a dashed outline and updates in
real time. Nothing is drawn when the chart timeframe is equal to or higher
than the selected HTF.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ HOW TO USE
Step 1 → Add the indicator on a lower timeframe chart (e.g., 5m or
15m). The HTF panel appears to the right of all candles.
Step 2 → Default HTF is 1H. Change it in settings to match the
context you trade (4H, D, etc.).
Step 3 → Solid boxes are completed HTF candles. Blue = bullish,
red = bearish.
Step 4 → The rightmost dashed box is the currently forming HTF
candle - it updates live on every bar close.
Step 5 → Set alerts for HTF Bullish or Bearish Candle Close to be
notified when the HTF period ends.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ HOW IT CALCULATES
◆ HTF OHLC via Built-In Resampling
The indicator uses request.security() with lookahead_off to fetch the
current HTF candle's OHLC on every bar:
= request.security(ticker, htf, )
Without lookahead, these values reflect only confirmed data up to the
current bar - no future leaking.
◆ Candle Completion Detection
A new HTF candle is detected using ta.change(time(htf_tf)). When the time
bucket changes, the previous candle is complete. At that moment:
htf_o , htf_h , htf_l , htf_c = OHLC of the completed candle
These are pushed to history arrays (up to History Count entries), and
the oldest entry is trimmed when the limit is reached.
◆ Panel Positioning
All candles are drawn to the right of the last chart bar:
x1 = bar_index + right_margin + i x (candle_width + gap)
x2 = x1 + candle_width
Positions are recalculated on every barstate.islast update. Previous
drawing objects are deleted and rebuilt each bar so the panel always
aligns with the current last bar as new data arrives.
◆ Completed Candle Rendering
Each completed candle is drawn as:
- Body: box from max(open, close) to min(open, close)
- Upper wick: line from high to body top (only if high > body top)
- Lower wick: line from body bottom to low (only if low < body bottom)
◆ Current Candle (Dashed)
The forming candle uses the same box for fill but replaces the solid
border with four dashed lines (top, bottom, left, right edges) and
dashed wick lines. The body color reflects the live direction -
bullish (blue) if close >= open, bearish (red) otherwise.
◆ Timeframe Label Pinning
The HTF label above the panel is anchored to the highest candle in the
HTF panel (not the chart's overall high). This keeps the label stable
above the panel as price moves on the underlying chart.
◆ Timeframe Guard
The indicator checks timeframe.in_seconds() < timeframe.in_seconds(htf).
If the chart timeframe is equal to or higher than the HTF, no panel is
drawn.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ WHAT MAKES IT DIFFERENT
◆ Panel to the Right - No Overlap
HTF candles are positioned past the last chart bar so they never cover
price action. The panel shifts automatically as new bars arrive.
◆ Dashed Forming Candle
The current unfinished HTF candle is visually distinct (dashed outline)
so it is never confused with confirmed history.
◆ Stable Timeframe Label
The HTF label is pinned to the highest candle inside the panel itself
rather than the chart's overall high. The label position stays consistent
relative to the HTF panel even when underlying chart prices spike outside
the panel range.
◆ Non-Repainting OHLC
request.security() with lookahead_off ensures that completed candle
values are final before they are committed to history. No retrospective
changes occur to completed boxes.
◆ Timeframe Guard
The indicator automatically disables itself when the chart timeframe is
greater than or equal to the selected HTF — no panel is drawn,
preventing meaningless output.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ LEGEND
Legend table (bottom left) explains the visual elements:
▮ (blue) - Bullish completed HTF candle (solid outline)
▮ (red) - Bearish completed HTF candle (solid outline)
┅ (blue) - Currently forming HTF candle (dashed outline)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ SETTINGS
HTF Settings
HTF Timeframe - 60 (1H by default)
History Count - 5 (completed HTF candles to keep visible)
Show Current Candle - ON (show the forming candle with dashed outline)
Visualization
Bullish Color - blue (customizable)
Bearish Color - red (customizable)
Candle Width (bars) - 5 (width of each candle box)
Gap Between Candles - 2 (spacing between boxes)
Right Margin (bars) - 10 (distance from last chart bar to panel)
Dashboard
Show Legend - ON
Alert Settings
Allow Repainting - OFF
JSON Alerts - OFF
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
▸ ALERTS
HTF Bullish Candle Close - HTF candle closed bullish (close >= open)
HTF Bearish Candle Close - HTF candle closed bearish (close < open)
HTF Candle Close - any HTF candle closed
JSON payloads include direction, ticker, price, timeframe, htf, and indicator tag.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Best regards,
EXCAVO
Disclaimer
Trading involves significant risk. This indicator is a technical analysis tool
and does not constitute financial advice, investment recommendations, or a
guarantee of future results. Past indicator behavior does not guarantee future
performance. Always use proper risk management and your own judgment.
Pine Script® indicator






















