Hello,
Can somebody please assist. Trying to build CCI.
Error is as follows:
ValueError: 'nan' is not a valid variable name
class Commodity_Channel_Index(CustomFactor):
"""
CCI technical indicator.
https://www.tradingtechnologies.com/xtrader-help/x-study/technical-indicator-definitions/commodity-channel-index-cci/ # noqa
**Defaults Inputs:** USEquityPricing.low, USEquityPricing.high, USEquityPricing.close
Parameters
----------
window_length : int > 0
Length of the lookback window
"""
inputs = (USEquityPricing.low, USEquityPricing.high, USEquityPricing.close)
def compute(self, today, assets, out, low, high, close):
wl = self.window_length
high_p = np.nanmax(high, axis=0)
low_p = np.nanmin(low, axis=0)
M = (high_p + low_p + close[0])/3
m_a = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length = wl)
df = pd.Series(M-m_a)
D = df.mad()
evaluate(
'(M-m_a) / (0.015 *D)',
local_dict={
'M': M,
'm_a': m_a,
'D': D,
},
out=out,
)