ta.cog()
Center of Gravity
The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.
Syntax
ta.cog(source, length) → series floatArguments
| Parameter | Type | Description |
|---|---|---|
| source | series int/float | Series of values to process. |
| length | series int | Number of bars in the rolling window. |
Returns
Center of Gravity.
Remarks
na values in the source series are ignored.
Code Examples
//@version=6
indicator("ta.cog", overlay=true)
plot(ta.cog(close, 10))
// the same on pine
pine_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))Trading Applications
Identify price equilibrium points
Detect overbought/oversold using gravity concept
Build mean-reversion strategies
Use as a leading oscillator for price direction
Related Functions
Frequently Asked Questions
Generate ta.cog() Code with AI
Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.cog() and other built-in functions instantly.
Related Pine Script Functions
ta.stoch() - Stochastic Oscillator
Learn how to use ta.stoch() in Pine Script. Syntax, parameters, code examples for the Stochastic Oscillator.
ta.rsi() - Relative Strength Index
Learn how to use ta.rsi() in Pine Script. Syntax, parameters, code examples for the RSI momentum oscillator.
ta.linreg() - Linear Regression
Learn how to use ta.linreg() in Pine Script. Syntax, parameters, code examples for linear regression curve fitting.
ta.sma() - Simple Moving Average
Learn how to use ta.sma() in Pine Script. Syntax, parameters, code examples, and trading applications for the Simple Moving Average function.
ta.ema() - Exponential Moving Average
Learn how to use ta.ema() in Pine Script. Syntax, parameters, code examples, and trading applications for the Exponential Moving Average function.