alexgrover

Using The AM/GM Inequality To Estimate Volatility

A volatility indicator derived from the AM/GM inequality. I don't think it will be necessary to describe the usage and interpretation of such indicator, and I don't think it is super useful, however, this is not the case of the script, which contains three ways to compute the geometric mean, with a classic, a simple, and an efficient way. The AM/GM inequality is also a really interesting concept, and I'll try to"prove" it in this post by using DSP. I also added more comments in the script in order to highlight some stuff.

The AM/GM Inequality

When we talk about the mean, we are referring to the "arithmetic" one by default, but there exist more types of means. Two other ones include the "geometric" and "harmonic" means, both are part of the Pythagorean means with the arithmetic mean.

Each one of them as several properties, but the most interesting aspect is their inequality, that is:

HM <= GM <= AM

The arithmetic mean is the one with the highest value, while the harmonic mean is the one with the lowest value. In the case each data point is equal to each other, all the means have the same value.

In our case, the inequality of interest is the inequality between the geometric and arithmetic mean, where the geometric mean is lower or equal than the arithmetic one. Many proofs/explanations exist, I'll try my version using DSP, where instead of thinking about means, we think about rolling means, which allows us to interpret them as low-pass filters. So we end up having the geometric moving average (GMA) and arithmetic moving average (SMA).

We know that GMA <= SMA, the SMA has a unity passband, this implies that the GMA has a passband lower than 1 (for non-equal input values), this explains why the GMA is smaller than the SMA. In order for a FIR filter to have a passband lower than 1, the sum of the filter coefficients must be lower than 1. In order to further proves this consider the following equation:

sqrt(a×b) = k×a + k×b

Here sqrt(a×b) is the geometric mean of a and b, the right-hand side of the equation is a weighted sum between a and b and coefficient k, we want to solve the equation with respect to k, if k×2 < 1 then we have the proof that GMA < SMA. The solution with respect to k is:

k = sqrt(a×b)/(a+b)

which always gives a number lower than 0.5, as such k×2 < 1 and thus the passband is lower than 1. If our input values are equal to each other, we end up with the following solution for k:

k = sqrt(a×a)/(a+a) = a/(2×a) = 0.5

as such the GMA has the coefficients of an SMA as long as the input values are equal to each other.

Because of this inequality, we can subtract the SMA to a GMA and take the square root of the result in order to have a volatility indicator, however, both moving averages are still pretty close to each other, which gives a very small result for the indicator.

Uwu I am a bit tired, better indicators coming up

Check out the indicators we are making at luxalgo: www.tradingview.com/u/LuxAlgo/
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?