InvestorUnknown

Asset Drawdown & Drawdown HeatMap [InvestorUnknown]

Overview

The "Asset Drawdown & Drawdown HeatMap" indicator is designed for educational purposes to help users visualize and analyze the drawdowns of various assets. It highlights both recent and historical drawdowns, offering valuable insights into the performance and risk of different investments. Additionally, it can serve as a complementary analysis tool for trading and investing decisions.

Features

Drawdown Calculation:
  • Computes the drawdown from the highest value (ATH) to the current value, showing the percentage decline.
  • Displays both the current drawdown and the maximum historical drawdown for the selected assets.

HeatMap Visualization:
  • Uses a gradient color scheme to represent the magnitude of drawdowns over a specified lookback period.
  • Helps identify periods of significant decline and recovery visually.


Multiple Assets:
  • Supports up to 10 different assets (adding more would make it harder to see the drawdowns of different assets), allowing users to compare drawdowns across various symbols.
  • Each asset can be individually plotted and color-coded for clarity.


Customizable Settings:
  • User inputs for high and low value calculations, color preferences, and lookback periods.
  • Option to color bars based on the drawdown heatmap.

Detailed Functionality

Drawdown Calculation:
The DD() function calculates the current drawdown and the maximum historical drawdown based on the high and low values.
The drawdown is calculated as 100 - (lowvalue / ATH * 100), where ATH is the highest value observed so far.

// - - - - - Custom Function - - - - - //{
DD() =>
    ATH = highvalue
    ATH := na(ATH[1]) ? highvalue : math.max(highvalue, ATH[1])
    Drawdown = 100 - lowvalue / ATH * 100
    MaxDrawdown = Drawdown
    MaxDrawdown := na(MaxDrawdown[1]) ? Drawdown : math.max(Drawdown, MaxDrawdown[1])
    [Drawdown,MaxDrawdown]
//}

Security Request:
Uses the request.security() function to fetch drawdown data for each specified asset on a daily timeframe.
Computes both current drawdown (TnDD) and maximum drawdown (TnMDD) for each asset.

// - - - - - Create Variables - - - - - //{
[T0DD ,  T0MDD] = request.security("",  "1D", DD()) // Chart
[T1DD ,  T1MDD] = request.security(t1,  "1D", DD())
[T2DD ,  T2MDD] = request.security(t2,  "1D", DD())
[T3DD ,  T3MDD] = request.security(t3,  "1D", DD())
[T4DD ,  T4MDD] = request.security(t4,  "1D", DD())
[T5DD ,  T5MDD] = request.security(t5,  "1D", DD())
[T6DD ,  T6MDD] = request.security(t6,  "1D", DD())
[T7DD ,  T7MDD] = request.security(t7,  "1D", DD())
[T8DD ,  T8MDD] = request.security(t8,  "1D", DD())
[T9DD ,  T9MDD] = request.security(t9,  "1D", DD())
[T10DD, T10MDD] = request.security(t10, "1D", DD())
//}

Plotting:
Plots the drawdown values for each asset on the chart, with the option to enable or disable plotting for individual assets.
Colors the plotted lines and labels based on user-specified preferences.

HeatMap:
Creates a heatmap color gradient based on the drawdown values over the lookback period.
Colors the bars on the chart according to the heatmap to visualize drawdown severity over time.

// - - - - - HeatMap - - - - - //{
heatcol = color.from_gradient(T0DD, ta.lowest(T0DD,lookback), ta.highest(T0DD,lookback), topcol, botcol)
barcolor(colbars ? heatcol : na)
//}

Labels:
Displays labels for each asset's drawdown value at the end of the chart for quick reference.


This indicator is an excellent tool for educational purposes, helping users understand drawdown dynamics and their implications on asset performance. It also provides a visual aid for monitoring and comparing drawdowns across multiple assets, which can be beneficial for making informed trading and investment decisions.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?