Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT 7 Backtesting: How to Backtest Short and Long futures entries on Same Day

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

    NT 7 Backtesting: How to Backtest Short and Long futures entries on Same Day

    Hello,

    I am trying to backtest a futures product with a strategy that Enters Short and Long on the same day.

    I want to test both Short and Long Entries in the same backtest, and keep track of their Exits separately.

    My problem is that when I already have a long position, then try to enter short with a unique signalname, the short entry closes my long position.

    I need both long and short positions to stay open at the same time, just for the purposes of the backtest.

    How can I achieve this?

    I realize that in a real world futures account you can't be both long and short the same instrument. I am perfectly happy with strange/tricky solutions. I will program the best workaround that anybody out there can come up with.

    Thank you very much in advance,

    ChiTrader2000

    #2
    ChiTrader2000, the overall strategy position would count, and per strategy there would only be one, either long, short or flat - to realize your testing I would split things up and use 2 strategies, one for long trades, the other for the shorts.

    Comment


      #3
      Hi NinjaTrader_Bertrand,

      Thank you very much for the idea.

      If I did it that way, could I back-test both strategies at once, or would I have to back-test one and then the other? (I am willing to write a lot of code if needed, such as a "container strategy" that holds both strategies, to achieve my goal...)

      Currently, my NT7-based back-testing system requires the user to back-test buys in one back-test, then sells in a second back-test. My goal is to make it possible for users to back-test buys & sells in a single back-test.

      Thanks a lot,

      ChiTrader2000

      Comment


        #4
        Unfortunately you would need to backtest them separately in the Strategy Analyzer - the container strategy 'holding' the 2 directional ones would not help, since you would then steal have to deal with one strategy position only, which is not what you need for your purpose of testing each side independently.

        Comment


          #5
          Hi NinjaTrader_Bertrand,

          Thank you for your valuable help.

          It sounds like there is no possible way to do what I am trying to do.

          The only possible solution I can think of is to stop using NT's native order submission and filling, and do this:

          Since I am already using only market orders to simulate stop and limit orders, I could call this.EnterLong_Simulated(), etc., and this would 1) call a method called Fill_Simulated(), which would act like my current custom FillType does, then 2) call OrderUpdated_Simulated(), which would act like my OrderUpdated() code currently does. 3) I could draw entry and exit arrows on the chart, connected with a red or green line to denote profit and loss.

          4) I already keep track of every trade in a SQL Server db, and have created my own performance visualizer that is like NT7's, but specific for my company's own needs (best execution, with slippage, not P&L, and it's charts support baskets, like the COMBINED_RESULTS row, but it's graphical.

          The only big negative with my plan is that since NT7 wouldn't know that my simulated trades are actual trades, since I didn't use NT7's native Order Summission and Fill methods. This will cause problems like the showing of a quantity of "0" next to the 1000's of instruments in a single backtest, and th4e user would have to go to my visualizer for all aggregate data. Also, the user couldn't use the "Control-Arrow" hot keys to switch between the trades on the chart.

          Doing the solution above would allow buys and sells to be back-tested at the same time.

          If anybody has any further thoughts about back-testing buys and sells at the same time, I am very interested.

          NinjaTrader_Bertrand, Thanks again for your help,

          ChiTrader2000

          Comment


            #6
            ChiTrader2000,

            This approach may work for you, but you will essentially have to program your own backtesting and simulated trading engine. This is an interesting project but unfortunately we can't offer advice on the specific implementation for it.

            You may get quicker results by running separate strategies - one long and one short. The work remaining is then interpreting these separate results rather than recreating what NinjaTrader does already.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            592 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            554 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X