PROTECTED SOURCE SCRIPT

HTF Candle + OHLC Line Extensions

120
📈 Script Title:
HTF Candle + OHLC Line Extensions
✨ Capabilities Overview:
This Pine Script plots a dynamic Higher Timeframe (HTF) candle on your current (lower) chart.
It visually highlights:
• A solid "candle body" based on the highest close and lowest close within the selected HTF range.
• An optional wick representing the absolute high and low of that HTF period.
• Extended lines projecting the HTF Open, High, Low, and Close levels onto the current chart.
• Labels displaying the exact OHLC prices next to their respective lines.
• A central label naming the selected HTF.
This makes it easy to track HTF structure, key levels, and trends without switching chart timeframes.
________________________________________
⚙️ Inputs Explained and How to Set Them:
Input Name Description Recommended Settings
Higher Timeframe (htf_label) The timeframe to build the candle from (e.g., 4H, 1D, etc.). Choose a timeframe higher than your chart's timeframe (e.g., use 4H if on a 30min chart).
Offset to Right (bars) (offset_bars) Number of bars to shift the HTF candle to the right of current price action. Default 2 is good; increase if you want more spacing.
Show Wicks? (show_wicks) Toggles drawing of the wick (high-low range). Leave on for a more complete candle look. Turn off for cleaner appearance.
OHLC Line Color (line_color) Color of the Open, High, Low, Close extension lines. Pick a color that stands out on your chart (e.g., yellow).
OHLC Line Thickness (line_thickness) Thickness of the OHLC lines. Default 2 is visible but subtle. Increase for stronger emphasis.
OHLC Line Style (line_style) Solid, dotted, or dashed style for the OHLC lines. - Solid for strong levels
- Dotted for secondary importance
Candle Bullish Color (candle_up_color) Fill color for bullish HTF candles. Use a green shade.
Candle Bearish Color (candle_down_color) Fill color for bearish HTF candles. Use a red shade.
Bullish Wick Color (bullish_wick_color) Color of the wick for bullish candles. Match or slightly lighten the bullish candle color.
Bearish Wick Color (bearish_wick_color) Color of the wick for bearish candles. Match or slightly lighten the bearish candle color.
Bullish Border (bullish_candle_border) Color for the border of bullish candles. Usually match the candle body or make slightly darker.
Bearish Border (bearish_candle_border) Color for the border of bearish candles. Same principle as bullish borders.
Label Text Color (label_text_color) Text color for OHLC labels. White for dark charts; Black for light charts.
Label Background Color (label_bg_color) Background color for labels (for readability). Usually opposite of your chart background (e.g., black background on light charts).
________________________________________
📋 Detailed Script Behavior:
1. Timeframe Handling:
• Converts the user’s selection (htf_label) into minutes.
• Calculates how many chart bars make up the selected HTF period.
• Dynamically adapts even if the market is closed (no reliance on session endings).
2. HTF OHLC Calculation:
• Open: First bar’s open within HTF window.
• High/Low: Highest high and lowest low within HTF window.
• Close: Most recent bar’s close.
• High Close / Low Close: Highest and lowest closes for the candle body.
3. Plotting:
• Candle Body: Draws a box between highest close and lowest close.
• Wick: (Optional) Line connecting absolute High and Low.
• OHLC Lines: Drawn from where the price was observed to the HTF candle.
• Labels: Show precise O/H/L/C prices and the timeframe name.
________________________________________
📢 Important Usage Tips:
• Best Practice: Always select an HTF that’s higher than your current chart (for clarity).
For example:
o Chart: 15 min → HTF: 1H, 4H
o Chart: 1H → HTF: 4H, 1D
• Offset: If your chart is crowded, increase "Offset to Right" to move the candle visualization farther out.
• Customization: Adjust colors and line styles to match your chart theme for better visibility.
• Performance: Drawing many elements every bar is lightweight here, but on very high-frequency charts (like 1-min), it can cause slight lag.
________________________________________
🧠 Summary
This script is a powerful visual aid for traders who:
• Want to see HTF structure without changing charts.
• Like to track key HTF levels (especially Open, High, Low, Close).
• Prefer a minimal, customizable display that's easy to align with their chart styles.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.