Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Output Prints when Backtesting not showing in Output tab

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

    Output Prints when Backtesting not showing in Output tab

    Hey all I'm experiencing a slight problem. I'm trying to debug my code using print commands as suggested. I know the default out put is the output 1 tab for prints.

    I initially had the print command in an IF statement, but I was worried the IF statement wasn't being satisfied by the logic, so I decided to move it outside the IF statement and under the overall method of OnbarUpdate()

    However, I still get nothing showing up on the Output tab. Any recommendations? I am expecting that there isn't any difference between the program running during a backtest or a live test. So I am expecting the output to still occur.

    #2
    Hello RISKYBUSINEZZ,

    Thank you for your post.

    Do you receive any errors in the Log tab of the Control Center related to the script you are trying to debug? In some cases, a script may hit an error before it even reaches the logic in OnBarUpdate(). What is the Print statement you are trying to use?

    I look forward to your reply.

    Comment


      #3
      I get no errors the rest of the program runs as expected so far. It enters and exits trades as I am telling it to.

      All I am doing is saying, Print("Does this Work");

      Everything else in onbarupdate works as expected.

      Comment


        #4
        Here is the section of code. I had to grab it from my home computer.

        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        ​// contains all default values
        }

        else if (State == State.Configure)
        {
        AddDataSeries("MES 12-22", Data.BarsPeriodType.Minute, 1, Data.MarketDataType.Last);
        AddDataSeries("ES 12-22", Data.BarsPeriodType.Minute, 5, Data.MarketDataType.Last);
        }

        else if (State == State.DataLoaded)
        {
        // loads all my stuff
        }

        ​}



        protected override void OnBarUpdate()
        {
        Print("Does this work");

        if (BarsInProgress != 0)
        return;

        if (CurrentBars[0] < 7)
        return;

        // All functions execute as designed below this point

        }

        I am expecting this to simply make this print each time the bar updates.

        Comment


          #5
          Hello RISKYBUSINEZZ,

          Thank you for your reply.

          Please make sure that the script has been compiled before attempting to run the script. You may need to reload NinjaScript or remove then re-add the script after compiling to make sure the changes take effect. Additionally, please be sure that the strategy you are enabling is the same strategy that is being modified in the NinjaScript Editor. If you are still experiencing unexpected behavior after ensuring those items, please provide a reduced test script that I may try on my end. You may do this by creating a copy of the script you are working with (Right-click NinjaScript Editor > Save As) then reduce the code to what is introducing the issue. Export the reduced script at Control Center > Tools > Export > NinjaScript Add-On and then attach the exported script to your reply here.

          I appreciate your patience and look forward to resolving this item with you.

          Comment


            #6
            But there should be output during a simulated back test correct? Assuming I am using the Print command correctly. I did compile the program before running the back test as you mention. I know that because I changed some default values and that shows up on the back test. If I come up with something tonight as I work on it I will post it here. Thanks.

            Comment


              #7
              I found out the solution to the output issue. So when you back test and want to see the output you have to have to go to Ninja Script editor, and from there you have a tab that says ninja script output. Here is a picture of what it looks like for your reference. Click image for larger version

Name:	image.png
Views:	79
Size:	6.8 KB
ID:	1224000

              Comment


                #8
                Also you can view it from the normal output, just have to have the output tabs open first.

                Comment


                  #9
                  Hello RISKYBUSINEZZ,

                  Thank you for the update.

                  I am glad you clarified the solution; it sounds like you did not have the NinjaScript Output window open before running the backtest. Prints will only show if the Print() method is called while the Output window is already open. If you Run the backtest first and then open the NinjaScript Output window, it is expected for the window to be blank because the script has stopped running at that point and is not actively making any prints.

                  I sincerely appreciate your patience. Please don't hesitate to reach out with any future NinjaTrader items we may assist you with.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Yesterday, 05:17 AM
                  0 responses
                  71 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  143 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  76 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  47 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  51 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X