Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order entry on simple strategy

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

    Order entry on simple strategy

    I wrote a simple strategy where I want to enter an order on the first bar that crosses an EMA. So far all I have managed to do is enter a long on the next bar.

    EnterLong enters one bar too late. Entering a limit order never executes.

    I am using day bars for the simulation.

    #2
    What is your CalculateOnBarClose set to? (I'm guessing TRUE).

    Comment


      #3
      Hello chartish,

      Thanks for your post.

      In addition to the question member sledge posed are you seeing this while back testing, market replay or live data?

      Comment


        #4
        I have tried setting it to false and removing it altogether. No change.

        Comment


          #5
          I am Backtesting.

          Comment


            #6
            Hello chartish,

            Thanks for your replies.

            When backtesting CalculateOnbarClose will be true because historical data does not contain the tics that made up the bar, only the finished values of the bar (Open, High, Low and close). Your code is executed at the end of the bar, if the code says to place an order then that order will be placed on the next bar which explains your observations.

            To provide intrabar fills, for backtesting, you can add a secondary dataseries that has a shorter timeframe. Here is a reference to sample code that shows this: http://ninjatrader.com/support/forum...ead.php?t=6652

            Comment


              #7
              So you have to have intraday data to do this?

              Comment


                #8
                Hello chartish,

                If you are using daily bars, in backtesting, your code will execute once, at the end of each bar. If you want your conditions to checked/executed sooner than the end of a daily bar then yes you will need intraday data.

                Comment


                  #9
                  Thanks. I appreciate you help.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DannyP96, 05-18-2026, 02:38 PM
                  1 response
                  29 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by CarlTrading, 05-11-2026, 05:56 AM
                  0 responses
                  117 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CarlTrading, 05-10-2026, 08:12 PM
                  0 responses
                  69 views
                  0 likes
                  Last Post CarlTrading  
                  Started by Hwop38, 05-04-2026, 07:02 PM
                  0 responses
                  227 views
                  0 likes
                  Last Post Hwop38
                  by Hwop38
                   
                  Started by Mindset, 04-21-2026, 06:46 AM
                  0 responses
                  309 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X