OPEN-SOURCE SCRIPT
Aggiornato

Historical & Periodic Key Levels

202
This TradingView indicator ("Historical & Periodic Key Levels" 📈) automatically plots significant price levels on your chart, providing a clear visual reference for potential support and resistance areas.

Key Levels Displayed 🔑:

* All-Time High (ATH) 🔼: The highest price reached in the available history for the instrument.
* All-Time Low (ATL) 🔽: The lowest price reached in the available history for the instrument.
* Previous Daily Close D: The closing price of the previous trading day.
* Previous Weekly Close W: The closing price of the previous trading week.
* Previous Monthly Close M: The closing price of the previous trading month.
* Previous Yearly Close Y: The closing price of the previous trading year.

Features ✨:

* Clear Visualization 👁️: Levels are plotted as horizontal lines, extending to the most recent bar.
* Customizable Visibility 🕶️: Toggle the display of each key level type (ATH, ATL, Daily, Weekly, Monthly, Yearly closes) individually via the input settings.
* Customizable Colors 🎨: Set distinct colors for ATH, ATL, and each of the periodic close lines to suit your charting preferences.
* Adjustable Line Width ―: Control the thickness of the ATH/ATL lines and the periodic close lines separately.
* Informative Labels 🏷️: On the most recent bar, labels display the value and type of each active level (e.g., "ATH - 01/01/23", "D Close"). The ATH/ATL labels also include the date the level was established.
* Dynamic Updates 🔄: ATH and ATL levels update automatically if new highs or lows are made.

How to Use 🛠️:


  1. 1. Add the "Key Levels" indicator to your TradingView chart.
    2. In the indicator settings, customize which levels you want to see (ATH, ATL, Daily Close, etc.).
    3. Adjust the colors and line widths for optimal visibility on your chart setup.
    4. Use the plotted lines as potential reference points for support, resistance, and overall market context.


This indicator is useful for traders who employ key historical and periodic price levels in their technical analysis strategy. It helps in quickly identifying significant price points without manual plotting.
Created by YouNesta ✍️
Note di rilascio
This TradingView indicator ("Historical & Periodic Key Levels" 📈) automatically plots significant price levels on your chart, providing a clear visual reference for potential support and resistance areas.

Key Levels Displayed 🔑:

* All-Time High (ATH) 🔼: The highest price reached in the available history for the instrument.
* All-Time Low (ATL) 🔽: The lowest price reached in the available history for the instrument.
* Previous Daily Close D: The closing price of the previous trading day.
* Previous Weekly Close W: The closing price of the previous trading week.
* Previous Monthly Close M: The closing price of the previous trading month.
* Previous Yearly Close Y: The closing price of the previous trading year.

Features ✨:

* Clear Visualization 👁️: Levels are plotted as horizontal lines, extending to the most recent bar.
* Customizable Visibility 🕶️: Toggle the display of each key level type (ATH, ATL, Daily, Weekly, Monthly, Yearly closes) individually via the input settings.
* Customizable Colors 🎨: Set distinct colors for ATH, ATL, and each of the periodic close lines to suit your charting preferences.
* Adjustable Line Width ―: Control the thickness of the ATH/ATL lines and the periodic close lines separately.
* Informative Labels 🏷️: On the most recent bar, labels display the value and type of each active level (e.g., "ATH - 01/01/23", "D Close"). The ATH/ATL labels also include the date the level was established.
* Dynamic Updates 🔄: ATH and ATL levels update automatically if new highs or lows are made.

How to Use 🛠️:


  1. 1. Add the "Key Levels" indicator to your TradingView chart.
    2. In the indicator settings, customize which levels you want to see (ATH, ATL, Daily Close, etc.).
    3. Adjust the colors and line widths for optimal visibility on your chart setup.
    4. Use the plotted lines as potential reference points for support, resistance, and overall market context.


This indicator is useful for traders who employ key historical and periodic price levels in their technical analysis strategy. It helps in quickly identifying significant price points without manual plotting.
Created by YouNesta ✍️ (Sol :4Qg3RJ3SqC3A5igRWo5u7qMBb8t8YqhcrguUVoS15cou)
Note di rilascio
**New Features & Enhancements:**

* **Advanced Label Customization:**
* **Customizable Label Text:** Users can now define custom text for All-Time High (ATH), All-Time Low (ATL), and all periodic close labels (Daily, Weekly, Monthly, Yearly) via the "Style" tab.
* **Customizable Label Position:** Added options in the "Style" tab to control the position (style) and text alignment of ATH/ATL labels and periodic close labels independently.
* **Dynamic Coloring for Periodic Closes:**
* Periodic close lines and their corresponding labels now dynamically change color to indicate whether the previous period's close was positive (close > open), negative (close < open), or neutral (close == open).
* Dedicated color inputs for "Positive" and "Negative" states for each periodic level (Daily, Weekly, Monthly, Yearly) are available in the "Style" tab.
* **Enhanced Default Color Scheme:**
* Periodic close levels now feature a default color scheme that progresses from lighter to darker shades based on the timeframe (Daily being the lightest, Yearly the darkest). This applies to base, positive, and negative color states.
* **Timeframe-Aware Level Display:**
* Periodic levels (lines and labels) are now automatically hidden if the chart's current timeframe matches the period of the level. For example, the "Daily Close" level will not be displayed when the chart is set to a daily timeframe, "Weekly Close" will be hidden on a weekly chart, and so forth for Monthly and Yearly levels. This reduces clutter on higher timeframe charts.
* **Improved Settings Organization:**
* Indicator settings have been reorganized into two main tabs:
* **Inputs:** Contains toggles for the visibility of each level (ATH, ATL, Daily, Weekly, Monthly, Yearly closes).
* **Style:** Consolidates all visual customization options, including line colors, line widths, label texts, label position settings, and the new positive/negative state colors for periodic closes.

**Technical Updates:**

* Resolved an issue with color definitions by switching from `color.from_hex` to `color.rgb` for broader compatibility.
* Label management functions were refactored to correctly apply changes to label style and text alignment by recreating labels when settings are modified.
Note di rilascio

Changelog:

  • Input Parameter Grouping: Reorganized input parameters into more descriptive and granular groups for improved user experience in the indicator settings.
    Affected inputs: All style and visibility inputs.
    Relevant functions: input.bool, input.color, input.string, input.int.
    Consolidated all "Periodic Levels" styling options (base colors, trend colors, common line/label styles) under a single input group: Periodic Levels Style.
    New group variable: group_periodic_style.
    Removed group variables: group_periodic_base, group_periodic_trend, group_periodic_common.
  • Base Color Functionality Removed:
    • Eliminated the separate input options for "base" colors (e.g.,
      Pine Script®
      color_daily_close
      ,
      Pine Script®
      color_weekly_close
      ,
      Pine Script®
      color_monthly_close
      ,
      Pine Script®
      color_yearly_close
      ).
      Removed inputs: color_daily_close, color_weekly_close, color_monthly_close, color_yearly_close.
    • Modified the
      Pine Script®
      f_get_periodic_color
      function:
      Removed the base_color parameter from the function signature.
      Logic changed: If a periodic level's closing price is equal to its opening price, the line will now use the corresponding positive_color instead of a distinct base color.
    • Updated all internal calls to
      Pine Script®
      f_get_periodic_color
      (for
      Pine Script®
      daily_plot_color
      ,
      Pine Script®
      weekly_plot_color
      ,
      Pine Script®
      monthly_plot_color
      ,
      Pine Script®
      yearly_plot_color
      ) to remove the base color argument.

Note di rilascio
Changelog:

  • Removed user-configurable input for label style (pin type) for both ATH/ATL and Periodic levels.
  • Implemented an automatic label style cycling mechanism to prevent overlapping labels at the same price level.
    Labels at the same Y-coordinate will now cycle through the following styles: `label.style_label_left`, `label.style_label_right`, `label.style_label_up`, and `label.style_label_down`.
    This is managed by tracking the count of labels at each price level on the last bar.
  • Changed the default label style to `label.style_label_left`. The style cycling for overlapping labels also starts with `label.style_label_left`.
  • Added global variables `G_STYLE_CYCLE` (array of styles) and `g_map_y_level_counts` (map to track label counts per level).
  • Added helper function `f_get_next_style_for_level` to determine the appropriate style for a label based on its level and the count of existing labels at that level.
  • Updated the label management section to use the new style determination logic before creating/updating labels.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.