OPEN-SOURCE SCRIPT

Bull Market Drawdowns V1.0 [ADRIDEM]

Bull Market Drawdowns V1.0 [ADRIDEM]

Overview

The Bull Market Drawdowns V1.0 script is designed to help visualize and analyze drawdowns during a bull market. This script calculates the highest high price from a specified start date, identifies drawdown periods, and plots the drawdown areas on the chart. It also highlights the maximum drawdowns and marks the start of the bull market, providing a clear visual representation of market performance and potential risk periods.

Unique Features of the New Script

  1. Default Timeframe Configuration: Allows users to set a default timeframe for analysis, providing flexibility in adapting the script to different trading strategies and market conditions.
  2. Customizable Bull Market Start Date: Users can define the start date of the bull market, ensuring the script calculates drawdowns from a specific point in time that aligns with their analysis.
  3. Drawdown Calculation and Visualization: Calculates drawdowns from the highest high since the bull market start date and plots the drawdown areas on the chart with distinct color fills for easy identification.
  4. Maximum Drawdown Tracking and Labeling: Tracks the maximum drawdown for each period and places labels on the chart to indicate significant drawdowns, helping traders identify and assess periods of higher risk.
  5. Bull Market Start Marker: Marks the start of the bull market on the chart with a label, providing a clear reference point for the beginning of the analysis period.


Originality and Usefulness

This script provides a unique and valuable tool by combining drawdown analysis with visual markers and customizable settings. By calculating and plotting drawdowns from a user-defined start date, traders can better understand the performance and risks associated with a bull market. The script’s ability to track and label maximum drawdowns adds further depth to the analysis, making it easier to identify critical periods of market retracement.

Signal Description

The script includes several key visual elements that enhance its usefulness for traders:

  • Drawdown Area: Plots the upper and lower boundaries of the drawdown area, filling the space between with a semi-transparent color. This helps traders easily identify periods of market retracement.
  • Maximum Drawdown Labels: Labels are placed on the chart to indicate the maximum drawdown for each period, providing clear markers for significant drawdowns.
  • Bull Market Start Marker: A label is placed at the start of the bull market, marking the beginning of the analysis period and helping traders contextualize the drawdown data.


These visual elements help quickly assess the extent and impact of drawdowns within a bull market, aiding in risk management and decision-making.

Detailed Description

Input Variables

  • Default Timeframe (`default_timeframe`): Defines the timeframe for the analysis. Default is 720 minutes
  • Bull Market Start Date (`start_date_input`): The starting date for the bull market analysis. Default is January 1, 2023


Functionality

  • Highest High Calculation: The script calculates the highest high price on the specified timeframe from the user-defined start date.

    ```pine
    var float highest_high = na
    if (time >= start_date)
    highest_high := na(highest_high[1]) ? high : math.max(highest_high[1], high)
    ```
  • Drawdown Calculation: Determines the drawdown starting point and calculates the drawdown percentage from the highest high.

    ```pine
    var float drawdown_start = na
    if (time >= start_date)
    drawdown_start := na(drawdown_start[1]) or high >= highest_high ? high : drawdown_start[1]

    drawdown = (drawdown_start - low) / drawdown_start * 100
    ```
  • Maximum Drawdown Tracking: Tracks the maximum drawdown for each period and places labels above the highest high when a new high is reached.

    ```pine
    var float max_drawdown = na
    var int max_drawdown_bar_index = na
    if (time >= start_date)
    if na(max_drawdown[1]) or high >= highest_high
    if not na(max_drawdown[1]) and not na(max_drawdown_bar_index) and max_drawdown[1] > 10
    label.new(x=max_drawdown_bar_index, y=drawdown_start[1], text="Max -" + str.tostring(max_drawdown[1], "#") + "%",
    color=color.red, style=label.style_label_down, textcolor=color.white, size=size.normal)
    max_drawdown := 0
    max_drawdown_bar_index := na
    else
    if na(max_drawdown[1]) or drawdown > max_drawdown[1]
    max_drawdown := drawdown
    max_drawdown_bar_index := bar_index
    ```
  • Drawdown Area Plotting: Plots the drawdown area with upper and lower boundaries and fills the area with a semi-transparent color.

    ```pine
    drawdown_area_upper = time >= start_date ? drawdown_start : na
    drawdown_area_lower = time >= start_date ? low : na

    p1 = plot(drawdown_area_upper, title="Drawdown Area Upper", color=color.rgb(255, 82, 82, 60), linewidth=1)
    p2 = plot(drawdown_area_lower, title="Drawdown Area Lower", color=color.rgb(255, 82, 82, 100), linewidth=1)
    fill(p1, p2, color=color.new(color.red, 90), title="Drawdown Fill")
    ```
  • Current Maximum Drawdown Label: Places a label on the chart to indicate the current maximum drawdown if it exceeds 10%.

    ```pine
    var label current_max_drawdown_label = na
    if (not na(max_drawdown) and max_drawdown > 10)
    current_max_drawdown_label := label.new(x=bar_index, y=drawdown_start, text="Max -" + str.tostring(max_drawdown, "#") + "%",
    color=color.red, style=label.style_label_down, textcolor=color.white, size=size.normal)

    if (not na(current_max_drawdown_label))
    label.delete(current_max_drawdown_label[1])
    ```
  • Bull Market Start Marker: Places a label at the start of the bull market to mark the beginning of the analysis period.

    ```pine
    var label bull_market_start_label = na
    if (time >= start_date and na(bull_market_start_label))
    bull_market_start_label := label.new(x=bar_index, y=high, text="Bull Market Start", color=color.blue, style=label.style_label_up, textcolor=color.white, size=size.normal)
    ```


How to Use

  1. Configuring Inputs: Adjust the default timeframe and start date for the bull market as needed. This allows the script to be tailored to different market conditions and trading strategies.
  2. Interpreting the Indicator: Use the drawdown areas and labels to identify periods of significant market retracement. Pay attention to the maximum drawdown labels to assess the risk during these periods.
  3. Signal Confirmation: Use the bull market start marker to contextualize drawdown data within the overall market trend. The combination of drawdown visualization and maximum drawdown labels helps in making informed trading decisions.


This script provides a detailed view of drawdowns during a bull market, helping traders make more informed decisions by understanding the extent and impact of market retracements. By combining customizable settings with visual markers and drawdown analysis, traders can better align their strategies with the underlying market conditions, thus improving their risk management and decision-making processes.
CyclesstatisticsSupport and Resistance

סקריפט קוד פתוח

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

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


גם על:

כתב ויתור