I am trying to create a weekly consolidator which gives me ADX values per week. Here is my code. The problem is that I always get 0 values for DI+ and DI- and 50 for ADX itself. Can someone help please?

 

        public ADXData(OptionsTradingBot algorithm, Symbol symbol)
        {
            _bot = algorithm;
            _symbol = symbol;

            // Initialize the RollingWindow to hold 5 instances of AverageDirectionalIndex
            _weeklyAdxWindow = new RollingWindow<AverageDirectionalIndex>(14);

            // Initialize daily ADX with a 14-period
            DailyAdx = _bot.ADX(symbol, 14, Resolution.Daily);

            // Use a consolidator to manually aggregate daily bars into weekly bars (5 trading days)
            _weeklyConsolidator = new TradeBarConsolidator(TimeSpan.FromDays(7));
            _weeklyConsolidator.DataConsolidated += OnWeeklyConsolidatorBar;

            // Add the consolidator for daily data
            algorithm.SubscriptionManager.AddConsolidator(symbol, _weeklyConsolidator);

            // Warm up the indicators with historical data
            WarmUpIndicators(algorithm, symbol);
        }

        private void WarmUpIndicators(OptionsTradingBot algorithm, Symbol symbol)
        {
            // Get daily history for warming up the weekly bars
            var dailyHistory = algorithm.History<TradeBar>(symbol, 100, Resolution.Daily);
            foreach (var bar in dailyHistory)
            {
                DailyAdx.Update(bar);
                // Feed the historical data into the weekly consolidator to build weekly bars
                _weeklyConsolidator.Update(bar);
            }
        }

        private void OnWeeklyConsolidatorBar(object sender, TradeBar consolidatedWeeklyBar)
{
    // Ensure the weekly bar is not created on Sundays or intraday times
    if (consolidatedWeeklyBar.Time.DayOfWeek != DayOfWeek.Sunday)
    {
        var weeklyAdx = new AverageDirectionalIndex(14); // ADX with a 14-period (adjust as necessary)

        // Update the ADX directly using the consolidated weekly bar
        weeklyAdx.Update(consolidatedWeeklyBar);
        /********************************* 
        THE WEEKLYADX ABOVE is ALWAYS 50 and DI- and DI+ are 0
        ***********************************/

        // Log the consolidated bar details for debugging
        LogHelper.LogInfo(_bot, $"Consolidated Weekly Bar: O={consolidatedWeeklyBar.Open}, H={consolidatedWeeklyBar.High}, L={consolidatedWeeklyBar.Low}, C={consolidatedWeeklyBar.Close}");

        // Check if ADX is updating correctly and log values
        var diPlus = weeklyAdx.PositiveDirectionalIndex.Current.Value;
        var diMinus = weeklyAdx.NegativeDirectionalIndex.Current.Value;
        var adxValue = weeklyAdx.Current.Value;

        LogHelper.LogInfo(_bot, $"DI+ = {diPlus}, DI- = {diMinus}, ADX = {adxValue}");

        // Add the calculated weekly ADX to the RollingWindow
        _weeklyAdxWindow.Add(weeklyAdx);

        // Optionally log the rolling window contents
        if (_bot._loggingVerbosity >= 3)
        {
            LogHelper.LogInfo(_bot, $"Rolling Window (weekly ADX objects): {_weeklyAdxWindow.Count} ADX values at {consolidatedWeeklyBar.Time}");
        }
    }
}