ta.cog() - Pine Script Function
ta.cog()
Section titled “ta.cog()”Overview
Section titled “Overview”The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.
Syntax
Section titled “Syntax”ta.cog(source, length) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | series int/float | Series of values to process. |
Returns
Section titled “Returns”Center of Gravity.
Remarks
Section titled “Remarks”- na values in the source series are ignored.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("ta.cog", overlay=true)plot(ta.cog(close, 10))// the same on pinepine_cog(source, length) => sum = math.sum(source, length) num = 0.0for i = 0 to length - 1 price = source[i] num := num + price * (i + 1) -num / sumplot(pine_cog(close, 10))