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

Programmatically checking for back-testing

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

    Programmatically checking for back-testing

    Hi,

    I would like to send myself an alert email under certain (crisis) conditions *if* I'm executing live, rather than in back-testing mode.

    Is there a way in my NinjaScript code to distinguish between the two conditions? How can I tell whether I'm truly "live" rather than under simulation?

    #2
    How about:

    if (Historical)
    // We are backtesting
    RayNinjaTrader Customer Service

    Comment


      #3
      Beautiful, thanks.

      Comment


        #4
        Something related... is there some way to programmatically determine that I'm on the *last* bar of my backtest run? I am accumulating some of my own statistics, and this would be the right time to dump it to the output.

        Comment


          #5
          Try comparing CurrentBar to Count.



          RayNinjaTrader Customer Service

          Comment


            #6
            Ray,

            You know, that *should* work... but it doesn't seem to, at least not on the first test I just ran. The logic wasn't working for me... so I tried printing CurrentBar and Count every time into the update function... but it ends with this:

            Currentbar: 152, Count: 154

            Shouldn't the last CurrentBar be 153?

            Comment


              #7
              This back-test represented 60 minute bars over 22 days, so 154 bars should be the right result. Looks like the last bar was cut off before the end... perhaps the last bar, ending at 4:30 PM on the last day, isn't fed into the strategy for backtesting?

              As long as that's consistent behavior, not a big deal. I can just use Count-2 to compare CurrentCount against. Key is that it's consistent behavior...

              Comment


                #8
                Let us know if this is not consistent.
                RayNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Balage0922, Today, 07:38 AM
                0 responses
                5 views
                0 likes
                Last Post Balage0922  
                Started by JoMoon2024, Today, 06:56 AM
                0 responses
                6 views
                0 likes
                Last Post JoMoon2024  
                Started by Haiasi, 04-25-2024, 06:53 PM
                2 responses
                19 views
                0 likes
                Last Post Massinisa  
                Started by Creamers, Today, 05:32 AM
                0 responses
                6 views
                0 likes
                Last Post Creamers  
                Started by Segwin, 05-07-2018, 02:15 PM
                12 responses
                1,786 views
                0 likes
                Last Post Leafcutter  
                Working...
                X