Dynamic Autocorrelation Visualizer (YavuzAkbay)The Dynamic Autocorrelation Visualizer (DAV) is a specialized indicator that analyzes and displays the autocorrelation of closing prices over multiple time lags. The autocorrelation function is a well-established economic calculation that measures how past price movements correlate with current prices at various intervals. This indicator implements this function to provide traders with insights into how these correlations evolve over time, enabling them to identify shifts in market behavior and trends.
Key Features and Functionality
1. Input Parameters:
Max Lag: This parameter determines the maximum number of lags for which the autocorrelation will be calculated. By default, it is set to 10, allowing traders to observe the correlation from the most recent price up to 10 periods back.
Calculation Period: The period over which the autocorrelation is calculated, set by default to 50. This setting allows users to adapt the analysis to different time frames depending on their trading strategies.
2. Autocorrelation Calculation:
The DAV calculates the average closing price over the specified period using the Simple Moving Average (SMA). This average serves as a reference point for measuring deviations in price behavior.
It then computes the denominator for the autocorrelation formula, which is the sum of the squared differences between each closing price and the average price. This normalization ensures that the autocorrelation values are meaningful and statistically valid.
For each specified lag (from 0 to max_lag - 1), the indicator calculates the numerator by summing the product of deviations from the mean for both the current and lagged prices. The autocorrelation value for each lag is then derived by dividing the numerator by the denominator, producing a set of autocorrelation values that reflect the strength and direction of price relationships over time.
3. Visualization:
The results for each lag's autocorrelation are plotted as individual lines on the chart, each differentiated by color to represent different lag periods.
A zero line is drawn as a reference, helping traders easily identify when autocorrelation values cross from positive to negative or vice versa.
The color gradient from the brightest blue (for lag 1) to darker shades indicates the relative strength of the autocorrelation for each lag, providing an immediate visual cue for analysis.
Indicator is Useful for
Seeing how correlation patterns evolve
Identifying periods where the market changes its behavior
Spotting when certain lag patterns become more or less significant
How to Use the DAV Indicator
Before using the indicator, it should be backtested on the chart and the mechanics should be learned. In general, if all lags of the indicator are above 0, it means that the trend is continuing. When the lags start to fall below 0 one by one, it means a trend reversal or instability. The indicator is in a sense a 90 degree freeze trace of the Autocorrelation indicator that I have also integrated into Tradingview (available in my profile), so it may be more understandable if used in conjunction with this indicator.
Autocorrelogram
Autocorrelogram (YavuzAkbay)The Autocorrelogram (ACF) is a statistical tool designed for traders and analysts to evaluate the autocorrelation of price movements over time. Autocorrelation measures the correlation of a signal with a delayed version of itself, providing insights into the degree to which past price movements influence future price movements. This indicator is particularly useful for identifying trends and patterns in time series data, helping traders make informed decisions based on historical price behavior.
Key Components and Functionality
1. Input Parameters:
Sample Size: This parameter defines the number of data points used in the calculation of the autocorrelation function. A minimum value of 9 ensures statistical relevance. The default value is set to 100, which provides a broad view of the price behavior.
Data Source: Users can select the price data they wish to analyze (e.g., closing prices). This flexibility allows traders to apply the ACF to various price types, depending on their trading strategy.
Significance Level: This parameter determines the threshold for statistical significance in the autocorrelation values. The default value is set at 1.96, corresponding to a 95% confidence level, but users can adjust it to their preferences.
Calculate Change: This boolean option allows users to choose whether to calculate the change in the selected data source (e.g., daily price changes) rather than using the raw data. Analyzing changes can highlight momentum shifts that may be obscured in absolute price levels.
2. Core Calculations:
Simple Moving Average (SMA): The indicator computes the SMA of the selected data source over the defined sample size. This average serves as a baseline for assessing deviations in price behavior.
Variance Calculation: The variance of the price changes is calculated to understand the spread of the data. The variance is scaled by the sample size to ensure that the autocorrelation values are appropriately normalized.
Lag Value: The indicator calculates a lag value based on the sample size to determine how many periods back the autocorrelation will be calculated. This helps in assessing correlations at different time intervals.
3. Autocorrelation Calculation:
The script calculates the autocorrelation for lags ranging from 0 to 53. For each lag, it computes the autocovariance (the correlation of the signal with itself at different time intervals) and normalizes this by the variance. The result is a set of autocorrelation values that indicate the strength and direction of the relationship between current and past price movements.
4. Visualization:
The autocorrelation values are plotted as lines on the chart, with different colors indicating positive and negative correlations. Lines are dynamically drawn for each lag, providing a visual representation of how past prices influence current prices. A maximum of 54 lines (for lags 0 to 53) is maintained, with the oldest line being removed when the limit is exceeded.
Significance Levels: Horizontal lines are drawn at the defined significance levels, helping traders quickly identify when the autocorrelation values exceed the statistically significant threshold. These lines serve as benchmarks for interpreting the relevance of the autocorrelation values.
How to Use the ACF Indicator
Identifying Trends: Traders can use the ACF indicator to spot trends in the data. Strong positive autocorrelation at a given lag indicates that past price movements have a lasting influence on future movements, suggesting a potential continuation of the current trend. Conversely, significant negative autocorrelation may indicate reversals or mean reversion.
Decision Making: By comparing the autocorrelation values against the significance levels, traders can make informed decisions. For example, if the autocorrelation at lag 1 is significantly positive, it may suggest that a trend is likely to persist in the immediate future, prompting traders to consider long positions.
Setting Parameters: Adjusting the sample size and significance level allows traders to tailor the indicator to their specific market conditions and trading style. A larger sample size may provide more stable estimates but could obscure short-term fluctuations, while a smaller size may capture quick changes but with higher variability.
Combining with Other Indicators: The ACF can be used in conjunction with other technical indicators (like Moving Averages or RSI) to enhance trading strategies. Confirming signals from multiple indicators can provide stronger trade confirmations.
AutocorrelogramFast estimation of an autocorrelogram, more commonly called autocorrelation function (ACF). The script sets the maximum lag as 10*log10(N)-1 and sets the autocorrelation at lag 0 to 1.
Length controls the number of past observations of Src to use as input, while Differentiate Src perform first order differencing to Src before calculating the autoccorelations.
The ACF can return a lot of information, for technical analysis, the ACF can be used to determine whether the market is trending or ranging. Without prior processing, we expect trending prices to have a slowly decaying ACF with significant autocorrelation at each lag, while ranging prices will have an ACF that decay faster toward 0.
I won't post a lot on this profile, I'll post most of my future work on the LuxAlgo profile instead, link in the signature.