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

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
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RubenCazorla, Today, 09:07 AM
        2 responses
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by i019945nj, 12-14-2023, 06:41 AM
        7 responses
        82 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by timmbbo, 07-05-2023, 10:21 PM
        4 responses
        158 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by tkaboris, Today, 08:01 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Lumbeezl, 01-11-2022, 06:50 PM
        31 responses
        820 views
        1 like
        Last Post NinjaTrader_Adrian  
        Working...
        X