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.

# Autocorrelation_function

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.

APA-Adaptive, Ehlers Early Onset Trend [Loxx]APA-Adaptive, Ehlers Early Onset Trend is Ehlers Early Onset Trend but with Autocorrelation Periodogram Algorithm dominant cycle period input.
What is Ehlers Early Onset Trend?
The Onset Trend Detector study is a trend analyzing technical indicator developed by John F. Ehlers , based on a non-linear quotient transform. Two of Mr. Ehlers' previous studies, the Super Smoother Filter and the Roofing Filter, were used and expanded to create this new complex technical indicator. Being a trend-following analysis technique, its main purpose is to address the problem of lag that is common among moving average type indicators.
The Onset Trend Detector first applies the EhlersRoofingFilter to the input data in order to eliminate cyclic components with periods longer than, for example, 100 bars (default value, customizable via input parameters) as those are considered spectral dilation. Filtered data is then subjected to re-filtering by the Super Smoother Filter so that the noise (cyclic components with low length) is reduced to minimum. The period of 10 bars is a default maximum value for a wave cycle to be considered noise; it can be customized via input parameters as well. Once the data is cleared of both noise and spectral dilation, the filter processes it with the automatic gain control algorithm which is widely used in digital signal processing. This algorithm registers the most recent peak value and normalizes it; the normalized value slowly decays until the next peak swing. The ratio of previously filtered value to the corresponding peak value is then quotiently transformed to provide the resulting oscillator. The quotient transform is controlled by the K coefficient: its allowed values are in the range from -1 to +1. K values close to 1 leave the ratio almost untouched, those close to -1 will translate it to around the additive inverse, and those close to zero will collapse small values of the ratio while keeping the higher values high.
Indicator values around 1 signify uptrend and those around -1, downtrend.
What is an adaptive cycle, and what is Ehlers Autocorrelation Periodogram Algorithm?
From his Ehlers' book Cycle Analytics for Traders Advanced Technical Trading Concepts by John F. Ehlers , 2013, page 135:
"Adaptive filters can have several different meanings. For example, Perry Kaufman’s adaptive moving average ( KAMA ) and Tushar Chande’s variable index dynamic average ( VIDYA ) adapt to changes in volatility . By definition, these filters are reactive to price changes, and therefore they close the barn door after the horse is gone.The adaptive filters discussed in this chapter are the familiar Stochastic , relative strength index ( RSI ), commodity channel index ( CCI ), and band-pass filter.The key parameter in each case is the look-back period used to calculate the indicator. This look-back period is commonly a fixed value. However, since the measured cycle period is changing, it makes sense to adapt these indicators to the measured cycle period. When tradable market cycles are observed, they tend to persist for a short while.Therefore, by tuning the indicators to the measure cycle period they are optimized for current conditions and can even have predictive characteristics.
The dominant cycle period is measured using the Autocorrelation Periodogram Algorithm. That dominant cycle dynamically sets the look-back period for the indicators. I employ my own streamlined computation for the indicators that provide smoother and easier to interpret outputs than traditional methods. Further, the indicator codes have been modified to remove the effects of spectral dilation.This basically creates a whole new set of indicators for your trading arsenal."