fix: Improve ADX indicator calculation with proper Series conversion and parameter handling
This commit is contained in:
parent
071559a8e1
commit
8b9ef53794
@ -145,8 +145,17 @@ class DynamicStrategy(Strategy):
|
|||||||
|
|
||||||
elif ind_config['type'] == 'ADX':
|
elif ind_config['type'] == 'ADX':
|
||||||
def adx_calc(high, low, close):
|
def adx_calc(high, low, close):
|
||||||
result = ta.adx(high, low, close, length=int(ind_config['params']['length']))
|
result = ta.adx(high=pd.Series(high),
|
||||||
return result.fillna(method='ffill').fillna(0).values
|
low=pd.Series(low),
|
||||||
|
close=pd.Series(close),
|
||||||
|
length=int(ind_config['params']['length']),
|
||||||
|
lensig=14) # Adding lensig parameter
|
||||||
|
if isinstance(result, pd.DataFrame):
|
||||||
|
# ADX is typically the third column in the result
|
||||||
|
return result.iloc[:, 2].fillna(method='ffill').fillna(0).values
|
||||||
|
else:
|
||||||
|
# If result is a Series, return it directly
|
||||||
|
return result.fillna(method='ffill').fillna(0).values
|
||||||
self.indicators[ind_name] = self.I(adx_calc, self.data.High, self.data.Low, self.data.Close)
|
self.indicators[ind_name] = self.I(adx_calc, self.data.High, self.data.Low, self.data.Close)
|
||||||
|
|
||||||
elif ind_config['type'] == 'CCI':
|
elif ind_config['type'] == 'CCI':
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user