Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Chart won't update anymore

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Chart won't update anymore

    I had to completely skip trading today because my charts no longer update on Ninjatrader 8 as of this morning. I can see the prices changing in the Chart Trader panel to the right, but the candles don't update at all.

    This issue ONLY happens with NQ Dec24. MNQ DEC24 and other misc instruments charts update just fine. But NQ DEC24 doesn't update on the chart at all. Only in the Ask/Bid in Chart Trader.
    • I tried renaming the database file so it creates a fresh one. Didn't work.
    • I tried renaming cache folder so it creates a fresh one. Didn't work.
    • I tried using "Reload all historical data" and that makes it show "Loading..." on the chart for a long time, and then freezes the platform.
    • I tried restoring a previous version of my workspace. Didn't help.
    • I tried running repair installation. I'm on latest NT8 version.
    • I tried switching to a default workspace (futures) and all instruments work except for NQ DEC24... same issue.
    • Market playback works.
    Seems like a data problem with Ninjatrader/Tradovate. The datafeed is from my connected tradovate accounts.
    Last edited by iantriestrading; 09-26-2024, 08:31 AM.

    #2
    Hello iantriestrading,

    Thank you for posting.

    I have tested this on my end and cannot reproduce this behavior with NQ DEC24 selected. So I may look into this further please go to Help->Email Support and be sure to include Attn: Chris Jameson in the Subject line, a link to this thread in the body and a check in the box for "Log and trace files".

    Thanks in advance.
    Last edited by NinjaTrader_ChristopherJ; 09-26-2024, 09:33 AM.
    Christopher J.NinjaTrader Customer Service

    Comment


      #3
      Hey Christopher,

      I found out it was caused by my strategy which was meant to check for orphaned stop loss orders every 2 seconds and close them if found. I made this strategy to run on follower accounts since Apex Copier often leaves orphaned stop loss orders randomly on follower accounts.

      Do you see anything weird in the code? I'm not asking for help to fix, but i'm sharing here in case it can help anyone.



      Code:
      #region Using declarations
      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.ComponentModel.DataAnnotations;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Gui;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Gui.SuperDom;
      using NinjaTrader.Gui.Tools;
      using NinjaTrader.Data;
      using NinjaTrader.NinjaScript;
      using NinjaTrader.Core.FloatingPoint;
      using NinjaTrader.NinjaScript.Indicators;
      using NinjaTrader.NinjaScript.DrawingTools;
      #endregion
      namespace NinjaTrader.NinjaScript.Strategies
      {
          public class OrphanedStopLossCanceller : Strategy
          {
              private DateTime orphanedStopLossDetectedTime = DateTime.MinValue;
              private const int OrphanedStopLossThresholdSeconds = 2;
              protected override void OnStateChange()
              {
                  if (State == State.SetDefaults)
                  {
                      Name = "Orphaned Stop Loss Canceller";
                      Description = "Monitors and cancels orphaned stop loss orders";
                      Calculate = Calculate.OnEachTick;
                      EntriesPerDirection = 1;
                      EntryHandling = EntryHandling.AllEntries;
                      IsExitOnSessionCloseStrategy = true;
                      ExitOnSessionCloseSeconds = 30;
                      IsFillLimitOnTouch = false;
                      MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
                      OrderFillResolution = OrderFillResolution.Standard;
                      Slippage = 0;
                      StartBehavior = StartBehavior.WaitUntilFlat;
                      TimeInForce = TimeInForce.Gtc;
                      TraceOrders = false;
                      RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
                      StopTargetHandling = StopTargetHandling.PerEntryExecution;
                      BarsRequiredToTrade = 20;
                  }
                  else if (State == State.DataLoaded)
                  {
                      // Add any initialization logic here
                  }
              }
              protected override void OnBarUpdate()
              {
                  if (Position.MarketPosition == MarketPosition.Flat)
                  {
                      Order stopLossOrder = GetOrphanedStopLossOrder();
                    
                      if (stopLossOrder != null)
                      {
                          if (orphanedStopLossDetectedTime == DateTime.MinValue)
                          {
                              orphanedStopLossDetectedTime = Time[0];
                          }
                          else if ((Time[0] - orphanedStopLossDetectedTime).TotalSeconds >= OrphanedStopLossThresholdSeconds)
                          {
                              CancelOrder(stopLossOrder);
                              Print($"Cancelled orphaned stop loss order: {stopLossOrder.Name}, OrderId: {stopLossOrder.OrderId}");
                              orphanedStopLossDetectedTime = DateTime.MinValue;
                          }
                      }
                      else
                      {
                          orphanedStopLossDetectedTime = DateTime.MinValue;
                      }
                  }
                  else
                  {
                      orphanedStopLossDetectedTime = DateTime.MinValue;
                  }
              }
              private Order GetOrphanedStopLossOrder()
              {
                  return Orders.FirstOrDefault(o =>
                      o.Name == "Stop Loss" &&
                      o.OrderState == OrderState.Working &&
                      (o.OrderType == OrderType.StopMarket || o.OrderType == OrderType.StopLimit));
              }
          }
      }​

      Comment


        #4
        Hello iantriestrading,

        Running this script causes the bars on the chart to stop forming?

        You may be running out of CPU and memory resources.

        If you comment out all code in OnBarUpdate(), does the chart start updating?

        Uncomment each line one by one and check for the behavior. Which line when uncommented causes the chart bars to stop forming?

        Note, the Orders collection is not documented in the help guide and is not officially supported by the NinjaScript team.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        55 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        37 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        17 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        19 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        49 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X