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 Mindset, 04-21-2026, 06:46 AM
                  0 responses
                  117 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by M4ndoo, 04-20-2026, 05:21 PM
                  0 responses
                  166 views
                  0 likes
                  Last Post M4ndoo
                  by M4ndoo
                   
                  Started by M4ndoo, 04-19-2026, 05:54 PM
                  0 responses
                  85 views
                  0 likes
                  Last Post M4ndoo
                  by M4ndoo
                   
                  Started by cmoran13, 04-16-2026, 01:02 PM
                  0 responses
                  130 views
                  0 likes
                  Last Post cmoran13  
                  Started by PaulMohn, 04-10-2026, 11:11 AM
                  0 responses
                  88 views
                  0 likes
                  Last Post PaulMohn  
                  Working...
                  X