NellyN

Trend Quality Indicator

Description
This indicator is my interpretation in Pinescript of the "Trend-Quality Indicator" by David Sepiashvili.

The Trend Quality indicator (Q-indicator) is an attempt to estimate trend in relation to noise. It answers the long-standing question of whether a trend change qualifies as significant and promising, or insignificant and better ignored. In terms of noise, trend estimation not only determines whether the trend is reliable, but also allows you to measure its strength gradually. Thus, regardless of their prices, trends of various securities can easily be compared to each other or against any index.

The Trend Quality indicator (or Q-indicator) is a trend detection and estimation tool that is based on a two-step filtering technique. It measures cumulative price changes over term-oriented semi-cycles and relates them to “noise.” The approach reveals congestion and trending periods of the price movement and focuses on the most important trends, evaluating their strength in the process. The indicator is presented in a centered oscillator and banded oscillator format.

Calculation and Logic
To estimate the price dynamics, the cumulative price change (CPC) indicator is used, which measures the amount that the price has changed from a fixed starting point within a given semi-cycle. The CPC indicator is calculated as a cumulative sum of differences between the current and previous prices over the period from the fixed starting point t0. The trend within the given semi cycle can be found by calculating the moving average of the cumulative price change:
Trend = MA (CPC, m, t => t0)
Segmenting the price time series and constructing trends within the extracted semi-cycles offers the smallest average gap between actual and averaged data points. This results in a better fit of the real price dynamics.

Estimating Trend Performance
A basic criterion for estimating trend performance is the amount the trend changes over up or down semi-cycles. If there is little or no visible progress in the trend, it may be considered as nonefficient. Further, significant changes in trend may be considered as promising trading opportunities, but the term “significant” is relative and subject to interpretation.
The Q-indicator is calculated by dividing trend by noise with an appropriate correction factor.
The denominator of the Q-indicator — noise — can be defined as the average deviation of the cumulative price change from the trend. To determine linear noise, first we calculate
the absolute value of the difference between CPC and trend, and then smooth it over the n-point period:
Noise1 = MA(I CPC Trend I,n)

High positive values suggest strong uptrend, low negative values signify strong downtrend, and values fluctuating around the zero level indicate that trend and noise are in equilibrium, i.e., non-trending conditions might be present.
The root mean square noise, similar to the conventional standard deviation, can be derived by summing the squares of the difference between CPC and trend over each of the preceding n-point periods, dividing the sum by n, and calculating the square root of the result.

The Q-indicator is intended to measure trend activity. Some benchmarks can be used to determine the strength of a trend. In the range of Q-indicator values from -1 to +1, the trend is buried beneath noise. It is preferable to stay out of this zone. The greater the Q, the less the risk of trading exceeds this level (absolute value of Q>2), it can be qualified as promising.

Readings in the range from +2 to +5, or from -2 to -5, can indicate moderate trending, and readings above Q=+5 or below Q=-5 indicate strong trending. Strong upward trending often leads to the security’s overvaluing, and strong downward trending often results in the security’s undervaluing. Readings exceeding strong trending benchmarks can indicate overbought or oversold conditions and signal that price action should be monitored closely.

Input Parameters’ Description
Fast Length - the number of bars used in calculation of fast SMA of Trending Periods.
Slow Length - the number of bars used in calculation of slow SMA of Trending Periods.
Trend Length - the number of bars upon which the trend is defined.
Noise Type - defines mechanism of defining noise: linear or root mean square.
Noise Length - the number of bars upon which noise is determined.
Correction Factor - multiplier used in noise calculation.
Threshold Value - In the range of Q-indicator values from -1 to +1, the trend is buried beneath noise. It is preferable to stay out of this zone. The greater the threshold Value of Q-Indicator, the less the risk of trading exceeds this level, it can be qualified as promising. Readings in the range from +2 to +5, or from -2 to -5, can indicate moderate trending, and readings above Q=+5 or below Q=-5 indicate strong trending.

Plots
Green = buying pressure
Red = selling pressure
Yellow = sideways
ZeroLine = the zero level

In the provided script, multi-timeframe analysis is achieved using the request.security function, which retrieves data from a different timeframe than the one on which the script is running.

Explanation of Multi-Timeframe Logic in Multi-Timeframe selection
• This option retrieves the Trend Quality (TQ) from a higher timeframe if the current chart is intraday.
• The higher timeframe is specified in minutes by the user and converted to a Pine Script timeframe string.
• If the current chart is not intraday or no higher timeframe is specified, the TQ is taken from the current timeframe

Summary:
• Trend Quality Indicator measures established TREND,
• can be used on different timeframes,
• works well on different timeframes,
• the threshold of 2 to 5 should be appropriate for most instruments. It can be modified in chart settings to adapt to your strategy.

The Trend Quality Indicator doesn't predict the future. It is intended to help traders assess the strength of the current trend, giving them a better understanding of the market conditions to make more informed trading choices.

Further Reading
1. "Trend-Quality Indicator" by David Sepiashvili. Technical Analysis of Stocks & Commodities, April 2004.

Script open-source

Dans le véritable esprit de TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par le règlement. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.

Vous voulez utiliser ce script sur un graphique ?