OPEN-SOURCE SCRIPT
4H Previous Candle + Fibonacci

Indicator Description: 4H Previous Candle + Fibonacci
This Pine Script (v5) indicator is a technical analysis tool designed for traders using the
TradingView platform. It allows for the visualization of key levels from the previous 4-
hour candle directly on any lower time frame.
1. Primary Objective
The indicator aims to provide a Higher Time Frame (HTF) perspective automatically.
By plotting the high, low, and Fibonacci retracement levels of the last closed 4H
candle, it helps identify institutional support and resistance zones without the need to
constantly switch time frames.
2. Key Features
Feature Description
Automatic 4H Levels
Automatically plots horizontal lines for the High and Low of the
previous 4H candle.
Dynamic Adaptation
Line colors and styles adapt based on whether the candle was
bullish (green) or bearish (red).
Fibonacci
Retracements
Calculates and displays customizable Fibonacci levels (e.g., 23.6%,
38.2%, 50%, 61.8%, 78.6%).
Dashboard (HUD)
A summary table in the top-right corner displays exact values and
the candle type.
3. Technical Functionality
Data Retrieval (Multi-Timeframe)
The script uses the request.security function to extract data from the 4-hour time
frame (“240”). Using the [1] index ensures the indicator is based on a closed candle,
eliminating any risk of “repainting” (levels changing during formation).
Fibonacci Calculation Logic
The calculation of Fibonacci levels is intelligent and directional:
Bullish Candle: The retracement is calculated from bottom to top (0% is at the
bottom).
Bearish Candle: The retracement is calculated from top to bottom (0% is at the
top).
4. Configuration Parameters
Users can customize the indicator via the settings menu:
Visual Settings: Toggle lines, adjust thickness, price labels, and decimal
precision.
Fibonacci Settings: Enable levels, choose colors, line thickness, and enter
custom retracement percentages.
5. Trading Use Cases
Bounce Zones: The 50% and 61.8% levels of the previous 4H candle are often
considered “Premium” or “Discount” zones where price tends to react.
Confluence: Use these levels alongside other indicators (RSI, moving averages)
to confirm entry points.
Risk Management: Place Stop Losses just beyond the previous 4H High or Low.
Document generated for the analysis of the “4H Previous Candle + Fibonacci” Pine
Script.
This Pine Script (v5) indicator is a technical analysis tool designed for traders using the
TradingView platform. It allows for the visualization of key levels from the previous 4-
hour candle directly on any lower time frame.
The indicator aims to provide a Higher Time Frame (HTF) perspective automatically.
By plotting the high, low, and Fibonacci retracement levels of the last closed 4H
candle, it helps identify institutional support and resistance zones without the need to
constantly switch time frames.
Feature Description
Automatic 4H Levels
Automatically plots horizontal lines for the High and Low of the
previous 4H candle.
Dynamic Adaptation
Line colors and styles adapt based on whether the candle was
bullish (green) or bearish (red).
Fibonacci
Retracements
Calculates and displays customizable Fibonacci levels (e.g., 23.6%,
38.2%, 50%, 61.8%, 78.6%).
Dashboard (HUD)
A summary table in the top-right corner displays exact values and
the candle type.
Data Retrieval (Multi-Timeframe)
The script uses the request.security function to extract data from the 4-hour time
frame (“240”). Using the [1] index ensures the indicator is based on a closed candle,
eliminating any risk of “repainting” (levels changing during formation).
Fibonacci Calculation Logic
The calculation of Fibonacci levels is intelligent and directional:
Bullish Candle: The retracement is calculated from bottom to top (0% is at the
bottom).
Bearish Candle: The retracement is calculated from top to bottom (0% is at the
top).
Users can customize the indicator via the settings menu:
Visual Settings: Toggle lines, adjust thickness, price labels, and decimal
precision.
Fibonacci Settings: Enable levels, choose colors, line thickness, and enter
custom retracement percentages.
Bounce Zones: The 50% and 61.8% levels of the previous 4H candle are often
considered “Premium” or “Discount” zones where price tends to react.
Confluence: Use these levels alongside other indicators (RSI, moving averages)
to confirm entry points.
Risk Management: Place Stop Losses just beyond the previous 4H High or Low.
Document generated for the analysis of the “4H Previous Candle + Fibonacci” Pine
Script.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.