OPEN-SOURCE SCRIPT

MA Correlation Coefficient

This script helps you visualize the correlation between the price of an asset and 4 moving averages of your choice. This indicator can help you identify trendy markets as well as trend-shifts.

Disclaimer
Bear in mind that there is always some lag when using Moving-Averages, hence the purpose of this indicator is as a trend identification tool rather than an entry-exit strategy.

Working Principle
The basic idea behind this indicator is the following:

  • In a trendy market you will find high correlation between price and all kinds of Moving-Averages. This works both ways, no matter bull or bear trend.
    תמונת-בזק
  • In sideways markets you might find a mix of correlations accross timeframes (2018) or high correlation with Low-Timeframe averages and low correlation with High-Timeframe averages (2021/2022).
    תמונת-בזק
  • Trend shifts might be characterised by a 'staircase' type of correlation (yellow), where the asset regains correlation with higher timeframe averages
    תמונת-בזקIndicator Options

    1. Source: data used for indicator calculation

    1. Correlation Window: size of moving window for correlation calculation

    2. Average Type:

    • Simple-Moving-Average (SMA)
    • Exponential-Moving-Average (EMA)
    • Hull-Moving-Average (HMA)
    • Volume-Weighted-Moving-Average (VWMA)


    3. Lookback: number of past candles to calculate average

    4. Gradient: modify gradient colors. ['Bottom', 'Centre', 'Top'] colors relate to ['Negative', 'Neutral', 'Positive'] correlation values.

    Plot Explanation

    The indicator plots, using colors, the correlation of the asset with 4 averages. For every candle, 4 correlation values are generated, corresponding to 4 colors. These 4 colors are stacked one on top of the other generating the patterns explained above. These patterns may help you identify what kind of market you're in.
correlationCorrelation Coefficient (CC)moving_averageMoving AveragesstatisticsTrend Analysis

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

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

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

כתב ויתור