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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.