Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Debugging Ninjascript with Visual Studio

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

    Debugging Ninjascript with Visual Studio

    Hi there,

    I am debugging an indicator that plots a line on the price chart with visual studio. It works fine with Debug Mode enabled in Ninjascript, attaching the NinjaTrader process in visual studio, and the breakpoint set. When I update or add the indicator on a chart, the code stops at the breakpoint as expect5ed. The issue is, as I step through the code and the indicator plots new lines, the chart is not updated. Actually, the chart is very much locked, which makes it really hard to debug if the indicator plot works as expected while stepping through the code.

    Is there a way to have the charts update while stepping through the code?

    BTW: I use the Draw.Line to update the drawing on the chart.

    Thanks,
    -Alaa

    #2
    Hello Alaa,

    Visual Studio's breakpoint will stop a program from executing. There is no way around that. The point of a breakpoint is to stop execution so that you can view the code where the execution stopped.

    You could use prints to get information in the NinjaScript Output without blocking execution.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea,

      I understand that the code execution would stop at breakpoints. What I meant is as you step through the code (after the breakpoints) and execute plot statements (i.e. DrawLine), the plot does not. For example, if in the OnBarUpdate(), you plot a line using DrawLine, then as you step through the code when the OnBArUpdate() is called, you would expect to see the plot updates. However, this is not happening and the plot only updates when the debug mode is exited. This limits the ability to debug what might cause a plot to be wrong.

      Using Print statement is of little help if you are debugging a problem with plotting on a chart.

      Thanks,
      -Alaa

      Comment


        #4
        Hello Alaa,

        Because the breakpoint stops execution the drawing object cannot be drawn until the execution continues. (You would probably have to continue many times as the rendering thread tries to render the object)

        Print is helpful everywhere. Especially with tracking flow (sequence of events) and understanding the behavior.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks. I will give that a try.

          -Alaa

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          576 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          553 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X