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 nightstalker, Today, 01:32 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Zachary  
                Started by kevinenergy, Yesterday, 12:01 PM
                7 responses
                23 views
                0 likes
                Last Post nightstalker  
                Started by DawnTreader, 05-08-2024, 05:58 PM
                15 responses
                49 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ZeroKuhl, Yesterday, 04:31 PM
                7 responses
                40 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by xepher101, Today, 12:19 PM
                1 response
                24 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X