Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter at Close, Exit next day Close

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

    Enter at Close, Exit next day Close

    I am backtesting a strategy on daily charts, whereby the entry would be on market close on the same day the signal is generated and the exit would be on the close of the next day.

    However, during backtesting, the entry is on next day open and exit is on the day after next open, which are 1 day late.

    How do I change the code such that it enter and exit the way I want it as describe in the first instance? Else my backtest results will be incorrect. Thanks.

    #2
    Hi tjendra, you would need to add a finer datastream for execution then to your daily chart. This reference sample will demonstrate how to achieve this - http://www.ninjatrader-support2.com/...ead.php?t=6652

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Hi tjendra, you would need to add a finer datastream for execution then to your daily chart. This reference sample will demonstrate how to achieve this - http://www.ninjatrader-support2.com/...ead.php?t=6652
      Hi Bertrand, I tried following the example but can't get it work as expected. My strategy is pretty simple, go short at close of daily bar if there was 2 consecutive higher close, exit close of next daily bar. Go long at close of daily bar if there was 2 consecutive lower close, exit close of next daily bar.

      I attached the graph which showed the intrabar entry and exit and also the output and source code of the strategy. The entry and exit shown on the graph is on the wrong bar and also doesn't tally with the output of the strategy.
      Attached Files

      Comment


        #4
        Hi Tjendra, the code looks ok, with the faster series as the secondary to submit the orders to. I guess you're probably wondering about the display as the entry is displayed at the next bar but at the correct price from the last daily close. You can add a Print statement like
        Code:
        Print(Time[0].ToString())
        to you EnterShort / EnterLong lines to match off the times with the Executions tab for review.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X