Introduction

Roughness of a signal is often non desired since smooth signals are easier to analyse, its logical to say that anything interacting with rough price is subject to decrease in accuracy/efficiency and can induce non desired effects such as whipsaws. Being able to measure it can give useful information and potentially avoid errors in an analysis.

It is said that roughness appear when a signal have high-frequencies (short wavelengths) components with considerable amplitudes, so its not wrong to say that "estimating roughness" can be derived into "estimating complexity".

Measuring Roughness

There are a lot of way to estimate roughness in a signal, the most well know method being the estimation of fractal dimensions. Here i will use a first order autocorrelation function.

Auto-correlation is defined by the linear relationship between a signal and a delayed version of itself, for exemple if the price goes on the same direction than the price i bars back then the auto-correlation will increase, else decrease. So what this have to do with roughness ? Well when the auto-correlation decrease it means that the dominant frequency is high, and therefore that the signal is rough.

Interpretation Of The Indicator

When the indicator is high it means that price is rough, when its low it indicate that price is smooth. Originally its the inverse way but i found that it was more convenient to do it this way. We can interpret low values of the indicator as a trending market but its not totally true, for example high values dont always indicate that the market is ranging.

Here the comparison with the indicator applied to price (orange) and a moving average (purple)

لقطة

The average measurement applied to a moving average is way lower than the one using the price, this is because a moving average is smoother than price.

Its also interesting to see that some trend strength estimator like efficiency ratio can treat huge volatility signals as trend as shown below.

لقطة

Here the efficiency ratio treat this volatile movement as a trending market, our indicator instead indicate that this movement is rough, such indication can avoid situation where price is followed by another huge volatile movement in the opposite direction.

Its important to make the distinction between volatility and trend strength, the trend is defined by low frequencies components of a signal, therefore measuring trend strength can be resumed as measuring the amplitude of such frequencies, but roughness estimation can do a great job as well.

Conclusion

I have showed how to estimate roughness in price and compared how our indicator behaved in comparison with a classic trend strength measurement tool. Filters or any other indicator can be way more efficient if they know how to filter according to a situation, more commonly smoothing more when price is rough and smoothing less when price is smooth. Its good to have a wider view of how market is behaving and not sticking with the binary view of "Trending" and "Ranging".

I hope you find a use to this script :)

Best Regards







complexityroughroughnesssmoothsurfacetrendTrend AnalysistrendstrengthVolatility

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الرمز في المنشور يخضع لقواعد‎‎قوانين الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟


Check out the indicators we are making at luxalgo: tradingview.com/u/LuxAlgo/
يعمل أيضًا:

إخلاء المسؤولية