OztheWoz

Pythagorean Moving Averages (and more)

OztheWoz アップデート済   
When you think of the question "take the mean of this dataset", you'd normally think of using the arithmetic mean because usually the norm is equal to 1; however, there are an infinite number of other types of means depending on the function norm (p).


Pythagoras' is credited for the main types of means: his harmonic mean, his geometric mean, and his arithmetic mean:
Harmonic Average (p = -1):
- Take the reciprocal of all the numbers in the dataset, add them all together, divide by the amount of numbers added together, then take the reciprocal of the final answer.
Geometric Average (p = 0):
- Multiply all the numbers in the dataset, then take the nth root where n is equal to the amount of number you multiplied together.
Arithmetic Mean (p = 1):
- Add all the numbers in the dataset, then divide by the amount of numbers you added by.

A couple other means included in this script were the quadratic mean (p = 2) and the cubic mean (p = 3).
Quadratic Mean (p = 2):
- Square every number in the dataset, then divide by the amount of numbers your added by, then take the square root.
Cubic Mean (p = 3):
- Cube every number in the dataset, then divide by the amount of numbers you added by, then take the cube root.


There are an infinite number of means for every scenario of p, but they begin to follow a pattern after p = 3.


Read more:
www.cs.uni.edu/~campbell/stat/pyth.html
en.wikipedia.org/wiki/Generalized_mean
en.wikipedia.org/wiki/Norm

Note: I added the functions for the quadratic mean and cubic mean, but since market charts don't have those types of graphs, the functions don't usually work. It's the same reason why sometimes you'll see the harmonic average not working.
Disclaimer: This is not financial or mathematical advice, please look for someone certified before making any decisions.
リリースノート:
Fixed the Quadratic Mean and the Cubic Mean.
オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

チャートでこのスクリプトを利用したいですか?