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

Odd Add() With Print() Results

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

    Odd Add() With Print() Results

    I'm trying to debug some code and running into inconsistent results when trying to debug it with Print statements.

    With 1 min. data series in the strategy analyzer and using
    Add(PeriodType.Day, 1); in the initialize section, nothing prints in the out put window with
    Print("this is a test"); in the OnBarUpdate() section. That is the only code in there.

    With Add(PeriodType.Minute, 5); in the initialize section, the print statement works fine.With both Add(PeriodType.Day, 1);
    Add(PeriodType.Minute, 5); in the initialize section, nothing prints.

    Same results with 60 min bars in the data series.

    Why does Add(PeriodType.Day, 1); kill the print statements?

    #2
    Maybe an exception is thrown... I had a similar problem where no output or error was shown. Adding a try/catch block in the init method and printing out the exception details showed the reason why it did not work...

    Code:
    protected override void Initialize() {
        Print("DEBUG: Initialize() - Start (" + DateTime.Now + ")");
        try {		
            // my code
        } catch (Exception e) {
            Print("DEBUG: Initialize() - Exception: " + e); 
        } finally {
            Print("DEBUG: Initialize() - End (" + DateTime.Now + ")");
        }
    }
    The log output will be shown in the output windows BTW
    Last edited by norsay; 05-09-2012, 12:41 AM.

    Comment


      #3
      Kentoes, likely the OnBarUpdate did not fire for your script as the BarsRequired was not satisfied for all series it loads, please try with more data loaded and then recheck.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Bertrand View Post
        Kentoes, likely the OnBarUpdate did not fire for your script as the BarsRequired was not satisfied for all series it loads, please try with more data loaded and then recheck.
        Five months of data used. Still nothing.
        Maybe an exception is thrown... I had a similar problem where no output or error was shown. Adding a try/catch block in the init method and printing out the exception details showed the reason why it did not work...
        All that printed:
        DEBUG: Initialize() - Start (5/9/2012 8:50:45 AM)
        DEBUG: Initialize() - End (5/9/2012 8:50:45 AM)

        Comment


          #5
          Which connection do you test with? Are you sure have daily data backfill available? Would the outcome from a chart be the same?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            So the init method does not throw an exception... Have you also tried to add the debug code of my post to the update method? Just to be sure it's called by NT and does not throw an exception... BTW it looks like the update method is called never again if there was an exception, even a 2nd run would not cause any problems!

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Which connection do you test with? Are you sure have daily data backfill available? Would the outcome from a chart be the same?
              No connection. I select the data in the left side of the strategy tester and verify that the data is there through historical data manager.
              Not sure what you mean by "Would the outcome from a chart be the same"

              Comment


                #8
                Hi Kentoes,

                The quickest way of checking if the amount of data is contributing is to set BarsRequired = 0. You may have 5 months of data, but it won't necessarily be used if your strategy settings are not setup correctly. An example would be if you had minimum bars required set to 20 bars and a strategy backtest that only goes back a few days. The minimum bars required for the added, daily series would never be met in that case.

                If you're still not seeing OnBarUpdate() prints, please let us know your strategy settings and your source for minute and daily data so we can setup a similar test here.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by DJ888, 04-16-2024, 06:09 PM
                5 responses
                14 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by samish18, Yesterday, 08:31 AM
                4 responses
                14 views
                0 likes
                Last Post elirion
                by elirion
                 
                Started by funk10101, Yesterday, 09:43 PM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                5 responses
                551 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by rtwave, 04-12-2024, 09:30 AM
                5 responses
                37 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X