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

Debug Code Line by line?

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

    Debug Code Line by line?

    I am new to ninjascripts so I am trying to learn by going thorough the build in indicators and strategies.

    What I want to do is start an indicator and see the code execute line by line and see the data and variable as they come in and how they are handled.

    Thanks,
    elkinm

    #2
    Just as an update, I saw in previous posts that it is possible to debug in VS Pro which requires attaching to the NT process. But it seems to be hit or miss.

    Is there a complete set of instructions or an official guide of how to do this?

    Thanks again.

    Comment


      #3
      Hello elkinm,
      Welcome to the forum and I am happy to assist you.

      Yes, you can debug NinjaScript codes via Visual Studios. Please refer here to know more http://www.ninjatrader.com/support/h..._debugging.htm

      You can also refer to this post which further discusses some easy way to debug a code


      Please let me know if I can assist you any further.
      JoydeepNinjaTrader Customer Service

      Comment


        #4
        you can add a print command after each line and it will print it to the output window


        #region variable

        if ( variable > 0 ){ X_COUNT = 1; }

        if ( variable < 0 ){ Y_COUNT = 3; }

        #endregion

        Print("some variable = " + X_COUNT + " / some other variable = " + Y_COUNT);

        Comment


          #5
          Thank you, that was exaclty what I was looking for.

          Comment


            #6
            What i do is create a variable and comment out the one i am not using [or just change the 0 to a 1]

            //int debug = 0;
            int debug = 1;

            then later in the code call it as a condition for all of the print lines

            if ( debug == 1 ){ Print("some variable = " + X_COUNT + " / some other variable = " + Y_COUNT); }

            if ( debug == 1 ){ Print("some other statement"); }

            that way i can turn all my debug output off or on with one variable

            Comment


              #7
              This works, but do I have to re-compile in debug mode every time I start NT, and re-load the files in VS as it does not work otherwise.

              Also, NT seems to crash frequently when debugging after hitting F10 or F11 and I have to start all over again. Is this typical when debugging?

              Comment


                #8
                Hello elkinm,
                Unfortunately debugging via Visual Studios is not supported by us. I leave this thread open for any forum member to through more light on it.
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by andrewtrades, Today, 04:57 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by chbruno, Today, 04:10 PM
                0 responses
                6 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                436 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                7 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                19 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X