Description
RISK ON/RISK OFF Indicator
This script is an implementation of the “Risk ON/OFF Indicator” in Pine Script, which is used in trading and investment analysis. Here’s a brief description and explanation of its main functions.
Key Features:
- Lookback Period: This parameter determines the number of bars to look back for calculating changes in prices and indicators.
- Source: It defines the financial instrument or market data used as the primary source for calculations. In this script, it appears to be mainly stock indices, commodities, bonds, currencies, and cryptocurrencies.
- Calculation of Market and Reference Changes: The script calculates the percentage change in the current market data and various reference instruments over the specified lookback period. These changes are used to gauge the market sentiment and risk appetite.
- Risk Components: Different asset classes such as volatility (VIX), stocks (DJI), commodities (e.g., gold, silver, copper), bonds (US10Y), currencies (e.g., NZDUSD, AUDJPY), junk bonds (HYG), emerging markets (EEM), and cryptocurrencies are analyzed individually to assess their contribution to overall risk sentiment.
- Aggregation of Risk: The script aggregates the individual risk components using weighted averages to derive an overall risk sentiment measure.
- Beta Coefficient: It calculates the beta coefficient, a measure of the volatility or systematic risk of a security or portfolio compared to the overall market.
- Trend Analysis: The script also includes trend analysis using moving averages to determine whether the market is in an uptrend or downtrend.
- Table Output: Finally, the script outputs the calculated risk-on/off status, overall risk level, correlation, beta coefficient, and trend in a table format for easy interpretation.
Usage: Тhe script aims to provide traders and investors with a comprehensive view of market sentiment and risk appetite based on various asset classes and indicators.