Skip to main content

cg

Calculate the Center of Gravity.

The Center of Gravity indicator, in short, is used to anticipate future price movements and to trade on price reversals as soon as they happen. However, just like other oscillators, the COG indicator returns the best results in range-bound markets and should be avoided when the price is trending. Traders who use it will be able to closely speculate the upcoming price change of the asset.

Example​

from openbb import obb

stock_data = obb.equity.price.historical(symbol='TSLA', start_date='2023-01-01', provider='fmp')
cg_data = obb.technical.cg(data=stock_data.results, length=14)

Parameters​

NameTypeDescriptionDefaultOptional
dataList[Data]The data to use for the COG calculation.False
indexstrIndex column name to use with data, by default "date"dateFalse
lengthintThe length of the COG, by default 1414False

Returns​

OBBject
results : List[Data]
The COG data.