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 burtoninlondon, Today, 12:38 AM
                0 responses
                10 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                14 views
                0 likes
                Last Post AaronKoRn  
                Started by carnitron, Yesterday, 08:42 PM
                0 responses
                11 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Yesterday, 07:51 PM
                0 responses
                14 views
                0 likes
                Last Post strategist007  
                Started by StockTrader88, 03-06-2021, 08:58 AM
                44 responses
                3,983 views
                3 likes
                Last Post jhudas88  
                Working...
                X