fix: Improve ADX indicator calculation with proper Series conversion and parameter handling
This commit is contained in:
parent
071559a8e1
commit
8b9ef53794
@ -145,7 +145,16 @@ class DynamicStrategy(Strategy):
|
||||
|
||||
elif ind_config['type'] == 'ADX':
|
||||
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),
|
||||
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)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user