Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry on the Current Bar

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

    Entry on the Current Bar

    When I code EnterLong(1, "Long1"), it always enters on the next bar.

    How do I cause an entry to occur on the current bar rather than the next bar? An example would be entering a trade on Mondays (i.e. Time[0].DayOfWeek == DayOfWeek.Monday).

    I could try to workaround by testing for Friday, hoping it will enter on Monday, but if Monday is a holiday, the trade would enter on Tuesday which is undesirable.

    I do understand that you have to be careful on entering on the current bar that you don't use information that you would not normally have until after the bar closes.

    Brooks

    #2
    Hi brooksrimes,

    What is your CalculateOnBarClose setting?

    For this, it should be false.
    TimNinjaTrader Customer Service

    Comment


      #3
      Hi Tim,

      It was true. I changed it to false and reran the test. Still is entering on the following bar/day.

      What else could I do?

      Brooks

      Comment


        #4
        Hi brooksrimes,

        Is this during backtesting? If so, the behavior is expected, as the calculation are only done at the close of each bar.

        More info at - http://www.ninjatrader-support.com/H...TimeVsBacktest
        TimNinjaTrader Customer Service

        Comment


          #5
          I read the link. It didn't really help here.

          It seems like you are saying there is no way to code a backtest to "enter at the open of the current bar". If so, that's quite a restriction. It's easily done on other testing platforms I've used.

          Is there a way to code to "enter at the open of the next bar"?

          Brooks

          Comment


            #6
            Hi brooksrimes,

            During backtesting, the entry will occur one bar later, since the condition will not be satisfied until the end of the bar.

            You add granularity for backtesting purposes.
            More info at - http://www.ninjatrader.com/support/f...ead.php?t=6652
            TimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            56 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            143 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            160 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 05-10-2026, 08:12 PM
            0 responses
            96 views
            0 likes
            Last Post CarlTrading  
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            276 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Working...
            X