OPEN-SOURCE SCRIPT

META: Kahan Summation (Scripting Exercise)

2891
I was curious to see what Pine uses to accumulate numbers. It looks like it uses the simple "add em up" approach, rather than a compensated summation. This means that especially for large numbers, there is an inherent error amount.

This script implements the Kahan Summation Algorithm, also known as compensated summation.
en.wikipedia.org/wiki/Kahan_summation_algorithm

This is part 2 of my study into the builtin stdev function. I think this is why it differs so much from the simple two-pass solution.
META: STDEV Study (Scripting Exercise)

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.