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

Any way to exit backtest (without waiting for last bar) in C# strategy code?

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

    Any way to exit backtest (without waiting for last bar) in C# strategy code?

    Hello,

    I am running lengthy optimizations with multiple variables on dozens of futures contracts at once, and I would like to greatly speed up the process by by exiting out of the optimization's current backtest (current contract with current set of optimizable variables) before the last intraday bar of market data that is loaded in Ninja Trader for that contract.

    Can I do this in my Ninja Trader C# strategy code?

    More details: I am currently calculating the last date that I would like to test for each contract in the "Initialize()" method of my strategy, and I can write a Print() statement in the "OnBarUpdate()" that says "exit backtest now, since this contract has no more news events on future dates", but I an unable to exit the backtest at this point.

    Thanks in advance!
    ChiTrader2000

    #2
    ChiTrader2000,

    You cannot exit out of a backtest. You can only remove processing of your logic by an overarching if-statement. This will still mean you loop through all data points though. http://www.ninjatrader-support2.com/...ead.php?t=4804
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Josh,

      Thanks for the quick reply. I will "return;" on each OnBarUpate() event, per the samples in the link in your post.

      I am still, however, trying to think outside of the box for ways to make my optimizations run much faster.

      My tests are intraday tests that do not need 1 minute bar data on previous days, and we sometimes only trade a contract on a couple days of the year.

      What if I only imported one or two days of 1 minute bar data per year per contract (import only the days we have orders on), and skipped all the days in between? Would this make Ninja Trader proportionally faster (going from 100 days of data to 2 days)? Do you think that Ninja Trader would still work properly if I did this?

      Thanks again,
      ChiTrader2000

      Comment


        #4
        Hello,

        I will have Josh reply on Monday.
        DenNinjaTrader Customer Service

        Comment


          #5
          Sure. You can try it just don't connect to a data provider while you are doing it.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            NinjaTrader_Josh,

            Thanks for the info. I will give it a try.

            ChiTrader2000

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cutzpr, Today, 08:54 AM
            0 responses
            4 views
            0 likes
            Last Post cutzpr
            by cutzpr
             
            Started by benmarkal, Today, 08:44 AM
            0 responses
            5 views
            0 likes
            Last Post benmarkal  
            Started by Tin34, Today, 03:30 AM
            2 responses
            26 views
            0 likes
            Last Post Tin34
            by Tin34
             
            Started by sastrades, Yesterday, 09:59 AM
            2 responses
            38 views
            0 likes
            Last Post brucerobinson  
            Started by ETFVoyageur, Today, 12:52 AM
            1 response
            21 views
            0 likes
            Last Post Leeroy_Jenkins  
            Working...
            X