Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

NT & conditional breakpoints in VS Community 2013

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

    NT & conditional breakpoints in VS Community 2013

    I know VS debugging isn't officially supported, but a lot of users do use VS for script editing/debugging, so I thought I'd ask.

    Is there any known issue with debugging ninjascript in VS and using conditional breakpoints? I have a breakpoint with a condition of "CurrentBar == xxx", and execution blows right through that breakpoint, even though that line of code is executed while CurrentBar = xxx. Tried the same with "CurrentBar >= xxx". Same result.

    Maybe I'm just going about this incorrectly?

    #2
    Hello,

    Thank you for the question.

    I am unaware of any current problems surrounding breakpoints in Visual studio. Can you detail the process you are taking regarding Compile, when you enable debug mode, When you open VS etc.

    I wanted to see if the process you are taking is lacking any steps or if I can identify something that may cause this.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello,

      Thank you for the question.

      I am unaware of any current problems surrounding breakpoints in Visual studio. Can you detail the process you are taking regarding Compile, when you enable debug mode, When you open VS etc.

      I wanted to see if the process you are taking is lacking any steps or if I can identify something that may cause this.

      I look forward to being of further assistance.
      1. In debug mode in Ninjascript Editor
      2. With a script open in VS, I attach VS to the NT process.
      3. I recompile in NT (a different script, but I suppose that doesn't matter, since all ninjascripts are recompiled), and this activates the breakpoints in VS.
      4. In NT Control Center > Strategies tab, I tick the "Enable" box on a strategy to execute it.

      Regular breakpoints work fine and I am able to step through and step over code in VS. I'm only having trouble with conditional breakpoints.

      Comment


        #4
        So a little playing around shows that conditional breakpoints using hit counts works. So the problem must be with my syntax.

        CurrentBar == 100 (gets executed through without stopping)
        "CurrentBar" == 100 (error msg)
        CurrentBar = 100 (error msg)
        "CurrentBar == 100" (error msg)

        Can you see where I'm going wrong?

        Comment


          #5
          Hello,

          Thank you for the steps.

          I do see specifically with CurrentBar I am unable to use that in a conditional breakpoint working.

          What I did note is that using the following instead worked and I did see my breakpoints Print to the output:

          Code:
          //set conditional breakpoint on if (curBar == 100)
          //in conditional break I set up a print, I did see the print. 
          int curBar = CurrentBar;
          if (curBar == 100)
          {
          				
          }
          I just wanted to provide this back to let you know it is working, but at this point I am not certain why this is happening for the inherited property. I will need to research this further.

          Also when you attach, are you seeing the breakpoint as red or white? if it is white and you hold the mouse over it may say symbols have not been loaded, is this at all the case?

          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment


            #6
            Thanks Jesse. Good to know that I'm not losing my mind.

            I found a workaround similar to yours:

            Code:
            if (CurrentBar == 100)
             {
             System.Diagnostics.Debugger.Break();
             }

            Originally posted by NinjaTrader_Jesse View Post
            Also when you attach, are you seeing the breakpoint as red or white? if it is white and you hold the mouse over it may say symbols have not been loaded, is this at all the case?

            I look forward to being of further assistance.
            When I first attach VS to NT, the breakpoints are white with a red and black border. Once I recompile in the NS editor, the breakpoints are red.

            Since setting a conditional breakpoint on CurrentBar doesn't work, perhaps setting one on Time might? If so, it would be a rough equivalent since each CurrentBar corresponds to a particular Time.

            What would the syntax be for Time? E.g. -
            Time[0] == {2/20/2015 4:00:00 PM}

            Comment


              #7
              Hello,

              The Time[0] is just a DateTime object so you would need to make a DateTime that is of the time you want or use ToTime.

              I dont believe the problem is the type of object, I was still able to trigger the condition based on the CurrentBar but I had to make a local variable out of it.

              Code:
              int curBar = CurrentBar;
              In the condition I used curBar == 100 and that seemed to work fine. My observation would be that only the inherited property its self somehow is not making the connection in debug but I would need to research this further.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Thanks Jesse, that's a good workaround. Better than the one I was using since it allows changing the breakpoint's condition in the middle of debugging.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by zstheorist, Today, 07:52 PM
                0 responses
                3 views
                0 likes
                Last Post zstheorist  
                Started by pmachiraju, 11-01-2023, 04:46 AM
                8 responses
                149 views
                0 likes
                Last Post rehmans
                by rehmans
                 
                Started by mattbsea, Today, 05:44 PM
                0 responses
                5 views
                0 likes
                Last Post mattbsea  
                Started by RideMe, 04-07-2024, 04:54 PM
                6 responses
                33 views
                0 likes
                Last Post RideMe
                by RideMe
                 
                Started by tkaboris, Today, 05:13 PM
                0 responses
                5 views
                0 likes
                Last Post tkaboris  
                Working...
                X