diff --git a/pandas_ta/momentum/cg.py b/pandas_ta/momentum/cg.py index 6c49885..1379aa0 100644 --- a/pandas_ta/momentum/cg.py +++ b/pandas_ta/momentum/cg.py @@ -38,9 +38,9 @@ def cg( offset = v_offset(offset) # Calculate - coefficients = [length - i for i in range(0, length)] - numerator = -close.rolling(length).apply(weights(coefficients), raw=True) - cg = numerator / close.rolling(length).sum() + coefficients = range(1, length + 1) + numerator = close.rolling(length).apply(weights(coefficients), raw=True) + cg = -numerator / close.rolling(length).sum() # Offset if offset != 0: diff --git a/pandas_ta/overlap/linreg.py b/pandas_ta/overlap/linreg.py index c939cdb..3fb9b38 100644 --- a/pandas_ta/overlap/linreg.py +++ b/pandas_ta/overlap/linreg.py @@ -65,7 +65,7 @@ def linreg( # Calculate np_close = close.values - if Imports["talib"] and mode_tal: + if Imports["talib"] and mode_tal and not r: from talib import LINEARREG, LINEARREG_ANGLE, LINEARREG_INTERCEPT, LINEARREG_SLOPE, TSF if tsf: linreg = TSF(close, timeperiod=length)