adridem

Rolling Calmar Ratio with Ref Ticker V1.0 [ADRIDEM]

Overview

The Rolling Calmar Ratio with Ref Ticker script is designed to offer a comprehensive view of the Calmar ratios for a selected reference ticker and the current ticker. This script helps investors compare risk-adjusted returns between two assets over a rolling period, providing insights into their relative performance and risk. Below is a detailed presentation of the script and its unique features.

Unique Features of the New Script

  • Reference Ticker Comparison : Allows users to compare the Calmar ratio of the current ticker with a reference ticker, providing a relative performance analysis. Default ticker is BTCUSDT but can be changed.
  • Customizable Rolling Window : Enables users to set the length for the rolling window, adapting to different market conditions and timeframes. The default value is 252 bars, which approximates one year of trading days, but it can be adjusted as needed.
  • Smoothing Option : Includes an option to apply a smoothing simple moving average (SMA) to the Calmar ratios, helping to reduce noise and highlight trends. The smoothing length is customizable, with a default value of 14 bars.
  • Visual Indicators : Plots the smoothed Calmar ratios for both the reference ticker and the current ticker, with distinct colors for easy comparison. Additionally, a horizontal line helps identify key levels.
  • Dynamic Background Color : Adds a gray-blue transparent background between the Calmar ratio levels of 0 and 1, highlighting the critical region where risk-adjusted returns are assessed.

Originality and Usefulness

This script uniquely combines the analysis of Calmar ratios for a reference ticker and the current ticker, providing a comparative view of their risk-adjusted returns. The inclusion of a customizable rolling window and smoothing option enhances its adaptability and usefulness in various market conditions.

Signal Description

The script includes several features that highlight potential insights into the risk-adjusted returns of the assets:

  • Reference Ticker Calmar Ratio : Plotted as a red line, this represents the smoothed Calmar ratio for the user-selected reference ticker.
  • Current Ticker Calmar Ratio : Plotted as a white line, this represents the smoothed Calmar ratio for the current ticker.
  • Horizontal Lines and Background Color : A line at 0 helps to quickly identify the regions of positive and negative risk-adjusted returns.

These features assist in identifying relative performance differences and confirming the strength or weakness of risk-adjusted returns between the two tickers.

Detailed Description

Input Variables

  • Length for Rolling Window (`length`) : Defines the range for calculating the rolling Calmar ratio. Default is 252.
  • Smoothing Length (`smoothing_length`) : The number of periods for the smoothing SMA. Default is 14.
  • Reference Ticker (`ref_ticker`) : The ticker symbol for the reference asset. Default is "BINANCE:BTCUSDT".

Functionality

Calmar Ratio Calculation : The script calculates the cumulative returns and maximum drawdown for both the reference ticker and the current ticker. These values are used to compute the Calmar ratio.

```pine
ref_cumulativeReturn = (ref_close / ta.valuewhen(ta.lowest(ref_close, length) == ref_close, ref_close, 0)) - 1
ref_rollingMax = ta.highest(ref_close, length)
ref_drawdown = (ref_close - ref_rollingMax) / ref_rollingMax
ref_maxDrawdown = ta.lowest(ref_drawdown, length)
ref_calmarRatio = ref_cumulativeReturn / math.abs(ref_maxDrawdown)

current_cumulativeReturn = (close / ta.valuewhen(ta.lowest(close, length) == close, close, 0)) - 1
current_rollingMax = ta.highest(close, length)
current_drawdown = (close - current_rollingMax) / current_rollingMax
current_maxDrawdown = ta.lowest(current_drawdown, length)
current_calmarRatio = current_cumulativeReturn / math.abs(current_maxDrawdown)
```


Smoothing : A simple moving average is applied to the Calmar ratios to smooth the data.

```pine
smoothed_ref_calmarRatio = ta.sma(ref_calmarRatio, smoothing_length)
smoothed_current_calmarRatio = ta.sma(current_calmarRatio, smoothing_length)
```


Plotting : The script plots the smoothed Calmar ratios for both the reference ticker and the current ticker, along with a horizontal line.

```pine
plot(smoothed_ref_calmarRatio, title="Ref Ticker Calmar Ratio", color=color.rgb(255, 82, 82, 50), linewidth=2)
plot(smoothed_current_calmarRatio, title="Current Ticker Calmar Ratio", color=color.white, linewidth=2)
h0 = hline(0, "Zero Line", color=color.gray)
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")
```


How to Use

  • Configuring Inputs : Adjust the detection length and smoothing length as needed. Set the reference ticker to the desired asset for comparison.
  • Interpreting the Indicator : Use the plotted Calmar ratios and horizontal line to assess the relative risk-adjusted returns of the reference and current tickers.
  • Signal Confirmation : Look for differences in the Calmar ratios to identify potential performance advantages or weaknesses. The horizontal line helps to highlight key levels of risk-adjusted returns.

This script provides a detailed comparative view of risk-adjusted returns, aiding in more informed decision-making by highlighting key differences between the reference ticker and the current ticker.

Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?