Hi QuantConnect Community! I would like to ask your help.

Into Research Notebook, I want to calculate ADX indicator using consolidated data. I created a TradeBar object and add parameters in order to Update indicator. However, the results of

adx.Update(trade_bar)

 Is always False. I haven't been able to solve this problem.

Could you help me to find what is the mistake here? Below is the block of code:

# DF is DataFrame with consolidated data (OHLCV). The index is a DateTime object. # Previously, I dropped NaN values from DataFrame. # Define instance for ADX -> period=14 is the default value adx = AverageDirectionalIndex(period=14) # Dictionary to hold consolidated ADX values. adx_values = {'time': [], 'positiveDI': [], 'negativeDI': []} # DI+ and DI- requires a TradeBar object. trade_bar = TradeBar() # Iterate through consolidated dataframe. for item in DF.itertuples(): time = item.Index # Add parameters to "trade_bar" object trade_bar.Open = item.Open trade_bar.High = item.High trade_bar.Low = item.Low trade_bar.Close = item.Close trade_bar.EndTime = item.Index trade_bar.Volume = item.Volume # Update indicator with consolidated data adx.Update(trade_bar) # If indicator values are ready, append data to dictionary previosly defined if adx.IsReady: adx_values['time'].append(time) adx_values['positiveDI'].append(adx.PositiveDirectionalIndex.Current.Value) adx_values['negativeDI'].append(adx.NegativeDirectionalIndex.Current.Value) # Create indicator dataframe from dictionary consolidated_adx = pd.DataFrame(adx_values, columns=['time', 'positiveDI', 'negativeDI']) # Set index to time consolidated_adx = consolidated_adx.set_index('time')

 

Regards.

Author