Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exception in ChartTrader

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

    Exception in ChartTrader

    I've never seen this before in 1000s of hours of using NT8, and I'm not sure what's causing it.

    Nevertheless, giving it to you, so you can hand it to a programmer to see if they can diagnose the issue by inspection. There's a null reference in there, but the disassembled code has the source stripped, so I'm not entirely sure of what I'm looking at.

    Cheers

    P.S. for some inscrutable reason, the forum software is introducing spaces in odd places in the call stack below. When I fix them, and then repost, it just adds them back.

    . . .

    mscorlib.dll!System.ThrowHelper.ThrowInvalidOperat ionException(System.ExceptionResource resource) Line 60 C#
    mscorlib.dll!System.Collections.Generic.List<Syste m.__Canon>.Enumerator.MoveNextRare() Line 219 C#
    System.Core.dll!System.Linq.Enumerable.FirstOrDefa ult<NinjaTrader.Cbi.Position>(System.Collections.G eneric.IEnumerable<NinjaTrader.Cbi.Position> source, System.Func<NinjaTrader.Cbi.Position, bool> predicate) Line 2662 C#
    NinjaTrader.Gui.dll!NinjaTrader.Gui.Chart.ChartTra der.GetChartTraderPosition() Line 824 C#
    NinjaTrader.Gui.dll!NinjaTrader.Gui.Chart.Direct2D Form.RecalculateYAxisLabels(NinjaTrader.Gui.Chart. ScaleJustification scaleJustification, SharpDX.Direct2D1.RenderTarget renderTarget) Line 343 C#
    > NinjaTrader.Gui.dll!NinjaTrader.Gui.Chart.Direct2D Form.RenderInit() Line 394 C#
    NinjaTrader.Gui.dll!NinjaTrader.Gui.Chart.Direct2D Form.RenderToTarget(SharpDX.Direct2D1.RenderTarget renderTarget) Line 399 C#
    NinjaTrader.Gui.dll!NinjaTrader.Gui.Chart.Direct2D Form.OnPaint(System.Windows.Forms.PaintEventArgs e) Line 327 C#
    System.Windows.Forms.dll!System.Windows.Forms.Cont rol.PaintWithErrorHandling(System.Windows.Forms.Pa intEventArgs e, short layer) Line 12404 C#
    System.Windows.Forms.dll!System.Windows.Forms.Cont rol.WmPaint(ref System.Windows.Forms.Message m) Line 15232 C#
    System.Windows.Forms.dll!System.Windows.Forms.Cont rol.WndProc(ref System.Windows.Forms.Message m) Line 15526 C#
    System.Windows.Forms.dll!System.Windows.Forms.Form .WndProc(ref System.Windows.Forms.Message m) Line 6566 C#
    System.Windows.Forms.dll!System.Windows.Forms.Nati veWindow.Callback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam) Line 649 C#
    [Native to Managed Transition]
    [Managed to Native Transition]
    System.Windows.Forms.dll!System.Windows.Forms.Cont rol.Update() Line 14323 C#
    NinjaTrader.Gui.dll!NinjaTrader.Gui.Chart.ChartTra der.RefreshChart(NinjaTrader.Cbi.OrderEventArgs e) Line 652 C#
    NinjaTrader.Gui.dll!NinjaTrader.Gui.Chart.ChartTra der.OnOrderUpdate.AnonymousMethod__0() C#
    WindowsBase.dll!System.Windows.Threading.Exception Wrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 59 C#
    WindowsBase.dll!System.Windows.Threading.Exception Wrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 24 C#
    WindowsBase.dll!System.Windows.Threading.Dispatche rOperation.InvokeImpl() Line 440 C#
    mscorlib.dll!System.Threading.ExecutionContext.Run Internal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 515 C#
    mscorlib.dll!System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 486 C#
    mscorlib.dll!System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 479 C#
    WindowsBase.dll!MS.Internal.CulturePreservingExecu tionContext.Run(MS.Internal.CulturePreservingExecu tionContext executionContext, System.Threading.ContextCallback callback, object state) Line 85 C#
    WindowsBase.dll!System.Windows.Threading.Dispatche rOperation.Invoke() Line 362 C#
    WindowsBase.dll!System.Windows.Threading.Dispatche r.ProcessQueue() Line 1293 C#
    WindowsBase.dll!System.Windows.Threading.Dispatche r.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 1420 C#
    WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(Syste m.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 221 C#
    WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCa llbackOperation(object o) Line 253 C#
    WindowsBase.dll!System.Windows.Threading.Exception Wrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 73 C#
    WindowsBase.dll!System.Windows.Threading.Exception Wrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 24 C#
    WindowsBase.dll!System.Windows.Threading.Dispatche r.LegacyInvokeImpl(System.Windows.Threading.Dispat cherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Line 1021 C#
    WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndP roc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 207 C#
    [Native to Managed Transition]
    [Managed to Native Transition]
    WindowsBase.dll!System.Windows.Threading.Dispatche r.PushFrameImpl(System.Windows.Threading.Dispatche rFrame frame) Line 1329 C#
    NinjaTrader.Core.dll!NinjaTrader.Core.Globals.get_ RandomDispatcher.AnonymousMethod__0() C#
    mscorlib.dll!System.Threading.ExecutionContext.Run Internal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 515 C#
    mscorlib.dll!System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 486 C#
    mscorlib.dll!System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 479 C#
    mscorlib.dll!System.Threading.ThreadHelper.ThreadS tart() Line 65 C#
    Last edited by carnitron; 02-26-2025, 10:05 PM.

    #2
    Which version are you running?

    How often does this happen?

    Are you doing anything in particular when this happens?

    Are there any specific actions that seem to reproduce the problem?

    Comment


      #3
      Hello carnitron,

      Does the error occur when using any specific custom or 3rd party NinjaScript?

      As a test, see if the error can be reproduced in a clean environment with no custom scripts.

      To create a clean temporary NinjaTrader folder:
      1. Shutdown NinjaTrader
      2. Rename (My) Documents\NinjaTrader 8\ to (My) Documents\NinjaTrader 8.original\
      3. Download the NinjaTrader installation package from the link below
        1. NinjaTrader - Download
      4. Run the repair from this (if the repair is unsuccessful, uninstall and then re-install NinjaTrader)
      This will recreate the NinjaTrader 8 folder in (My) Documents.​

      Let me know if the error can be reproduced.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        So I can appreciate your desire for more information and reproduceable steps.

        I'm saying this is a rare one-off that I just saw randomly once. I wasn't doing anything out of the ordinary, I was just test running my algo as I always do.

        This is against 8.1.4.1, with no AddOns other than my own, which is nowhere present in the callstack.

        I'll see if it happens again in my daily operations, and if it does, I will update this post. But if it does not, then the only way forward is for a programmer to look at the call stack. That is not guaranteed to produce insights and a fix, but this is all the info we have, and it's clearly very rare, so maybe that's ok.

        Back when I worked in AAA video games, there were many instances of this kind of bug over the years, that came in from our crash logging service. You just had to look at the callstack and attempt to work out in your head what might be happening. Many times there wasn't enough info, but occasionally it was clear what the issue was, after some puzzling.

        Comment


          #5
          Did this exception occur recently?

          If so, I'm sure NT would love your trace/log files ...

          CC > Help > Email Support

          Comment


            #6
            Yes, it occurred yesterday evening. I have sent in logs and traces as you suggested. Good idea. Cheers.

            Comment


              #7
              I've seen this again. I'm going to have to keep an eye out as to why. This function seems highly relevant and is the culprit somehow:

              NinjaTrader.Gui.Chart.Direct2D Form.RecalculateYAxisLabels().

              Inside it, it is iterating an enumeration that I THINK might have been updated by another thread or modified reentrantly somehow during the enumeration:

              Code:
                  public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
                  {
                      if (source == null)
                      {
                          throw Error.ArgumentNull("source");
                      }
                      if (predicate == null)
                      {
                          throw Error.ArgumentNull("predicate");
                      }
                      foreach (TSource item in source)    // <-- happens right here.
                      {
                          if (predicate(item))
                          {
                              return item;
                          }
                      }
                      return default(TSource);
                  }
              Interestingly, we are scrolled to the left, so the action for the current trade is occurring offscreen to the right somewhere.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by trendisyourfriend, 05-25-2023, 09:54 AM
              10 responses
              159 views
              0 likes
              Last Post Curerious  
              Started by iantriestrading, Today, 04:12 PM
              0 responses
              10 views
              0 likes
              Last Post iantriestrading  
              Started by Adamel, Today, 03:47 PM
              0 responses
              8 views
              0 likes
              Last Post Adamel
              by Adamel
               
              Started by raysinred, 04-06-2025, 01:52 PM
              15 responses
              136 views
              0 likes
              Last Post NinjaTrader_Helom  
              Started by Str8boominit, 04-14-2025, 06:03 PM
              7 responses
              92 views
              0 likes
              Last Post NinjaTrader_Eduardo  
              Working...
              X