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

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 sofortune, Today, 10:05 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by ETFVoyageur, 05-07-2024, 07:05 PM
            23 responses
            185 views
            0 likes
            Last Post ETFVoyageur  
            Started by reynoldsn, 05-10-2024, 07:04 PM
            7 responses
            39 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by ETFVoyageur, Today, 02:15 AM
            5 responses
            31 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by drnoggin, Today, 12:19 PM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X