Skip to content
Algo Trade Analytics Docs

ta.cog() - Pine Script Function

The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.

ta.cog(source, length) → series float
NameTypeDescription
sourceseries int/floatSeries of values to process.

Center of Gravity.

  • na values in the source series are ignored.
//@version=6
indicator("ta.cog", overlay=true)
plot(ta.cog(close, 10))// the same on pinepine_cog(source, length) => sum = math.sum(source, length) num = 0.0
for i = 0 to length - 1 price = source[i] num := num + price * (i + 1) -num / sum
plot(pine_cog(close, 10))