Eyemaginative

Gap Trend Lines by @eyemaginative

Eyemaginative מעודכן   
Summary:
The "Gap Trend Lines" script is designed to identify and visualize gaps between the close of one candle and the opening of the next on a TradingView chart. It draws extended trend lines to visually connect these gaps, helping traders to identify significant price movements between consecutive candles.

Functionality:
Indicator Setup:
The script is set as an overlay indicator on the main chart.
It includes settings for maximum line and label counts, ensuring efficient performance.
Parameter Customization:
Gap Threshold: Defines the minimum gap size considered significant.
Line Colors: Allows customization of colors for small and large gaps.
Line Thickness and Style: Provides options to adjust the thickness and style (solid, dotted, dashed) of the trend lines.

Drawing Extended Trend Lines:

For each bar (candlestick) on the chart, the script checks if there is a gap between the previous candle's close and the current candle's open.
If a gap is detected (i.e., close != open), it determines the size of the gap.
Depending on the size relative to the defined threshold, it selects the appropriate color (small or large gap).
It then draws an extended trend line that starts from the close of the previous candle (bar_index, close) and extends to the open of the current candle (bar_index, open).
The trend line is drawn with the specified thickness, color, and style.

Dynamic Line Attribute Changes:

The script includes a function (changeLineAttributes()) that periodically changes the color and style of the trend lines.
By default, it changes the color every 4 hours (adjustable), alternating between green and the original color.

Enhanced Functionality:

Handles both small and large gaps with different visual cues (colors).
Supports extended trend lines that span both past and future directions (extend=extend.both), ensuring visibility across the entire chart.

Usage:

Traders can use the "Gap Trend Lines" script to:
Identify and analyze gaps between candlesticks.
Visualize significant price movements or breaks in continuity.
Customize the appearance of trend lines for better clarity and analysis.

By utilizing this script, traders can gain insights into price gap dynamics directly on TradingView charts, aiding in decision-making and strategy development.
הערות שחרור:
Update: This script now includes input parameters for customizing the color and style of lines that change every 4 hours. The default values for these parameters are green for color and dotted for style, but you can customize them as needed.

Summary:
The "Gap Trend Lines" script is designed to identify and visualize gaps between the close of one candle and the opening of the next on a TradingView chart. It draws extended trend lines to visually connect these gaps, helping traders to identify significant price movements between consecutive candles.

Functionality:
Indicator Setup:
The script is set as an overlay indicator on the main chart.
It includes settings for maximum line and label counts, ensuring efficient performance.
Parameter Customization:
Gap Threshold: Defines the minimum gap size considered significant.
Line Colors: Allows customization of colors for small and large gaps.
Line Thickness and Style: Provides options to adjust the thickness and style (solid, dotted, dashed) of the trend lines.

Drawing Extended Trend Lines:

For each bar (candlestick) on the chart, the script checks if there is a gap between the previous candle's close and the current candle's open.
If a gap is detected (i.e., close != open), it determines the size of the gap.
Depending on the size relative to the defined threshold, it selects the appropriate color (small or large gap).
It then draws an extended trend line that starts from the close of the previous candle (bar_index, close) and extends to the open of the current candle (bar_index, open).
The trend line is drawn with the specified thickness, color, and style.

Dynamic Line Attribute Changes:

The script includes a function (changeLineAttributes()) that periodically changes the color and style of the trend lines.
By default, it changes the color every 4 hours (adjustable), alternating between green and the original color.

Enhanced Functionality:

Handles both small and large gaps with different visual cues (colors).
Supports extended trend lines that span both past and future directions (extend=extend.both), ensuring visibility across the entire chart.

Usage:

Traders can use the "Gap Trend Lines" script to:
Identify and analyze gaps between candlesticks.
Visualize significant price movements or breaks in continuity.
Customize the appearance of trend lines for better clarity and analysis.

By utilizing this script, traders can gain insights into price gap dynamics directly on TradingView charts, aiding in decision-making and strategy development.
הערות שחרור:
Updated Indicator Image, No Script Update
הערות שחרור:
Changed Sample Image, No Script Change
הערות שחרור:
NOTE: There still exists an issue when refreshing browser where the script will need removed and readded due to a compile error. It compiles initially and will function until a refresh. I will resolve this in a future update.

Changes Made in this Release:
Added Independent Customization:

Added separate customization for small and large gaps, including line thickness and style.
Parameters for old gap customization included color, thickness, and style.
Dynamic Deletion of Lines:

Ensured delete_all_lines() function only deletes lines when necessary to avoid compilation issues upon refresh.
Error Handling:

Checked if trendLines array is empty before performing operations on it, preventing out-of-bounds errors.
Refined Periodic Change Function:

Added more granular control over the appearance of lines older than 4 hours, allowing customization from the input parameters.

This version ensures the script dynamically updates on changes and prevents issues with array bounds, providing robust functionality for identifying and visualizing price gaps.

Key Features:
Gap Detection: Identifies gaps where the close price of one candle is different from the open price of the next.

Line Drawing: Draws extended trend lines between these gaps, with customizable colors, thicknesses, and styles based on the gap size.

Periodic Change: Changes the color and style of lines that are older than 4 hours, with customizable parameters.

Dynamic Updates: Ensures the script updates dynamically when the gap threshold changes.

Customization Parameters:
Gap Threshold: Determines the size of gaps to be considered.

Small Gaps: Customizable color, thickness, and style for lines representing small gaps.
Large Gaps: Customizable color, thickness, and style for lines representing large gaps.
Old Gaps: Customizable color, thickness, and style for lines older than 4 hours.

Functions:
get_line_style(): Converts string input to the corresponding line style.
delete_all_lines(): Deletes all existing lines to prevent accumulation on parameter changes.
changeLineAttributes(): Changes the appearance of lines older than 4 hours based on specified intervals.
הערות שחרור:
Preventing Large Gap Lines from Becoming Old Gap Lines:

Initially, the script was treating all gap lines that persisted beyond a certain age as old gap lines. This included both small and large gap lines.

To differentiate between large and old gap lines, we modified the condition in the changeLineAttributes function. Now, only lines categorized as small gaps are allowed to age into old gap lines. Large gap lines retain their original attributes without turning into old gap lines.

Adding Hidden Line Options in Input Settings:

Three checkboxes were added to the input settings: Hide Small Gaps, Hide Large Gaps, and Hide Old Gaps.

Each checkbox allows the user to toggle the visibility of specific types of gap trend lines independently.

The update_visibility function was updated to read these settings and adjust the visibility of lines accordingly. Lines are hidden based on their type (small, large, or old) and whether the respective checkbox is checked.

These changes enable more flexible control over which types of gap trend lines are displayed on the chart, improving usability and customization options for the indicator.
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יכולים להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?