Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order fill date and execution date

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

    Order fill date and execution date

    I'm writing my first NT strategy and I've got problem:
    order is filled "today" at 00:00 but executed "next day" at 00:00. Why is not executed the same day?

    Second question: how can I open position not at open price but at open price-20pips? I tried with EnterShortLimit() but position is closing at price out of the bar few days later (at price from one before bar).

    I work on daily bars for forex currency pair.
    Below is code which opens short position - part on the OnBarUpdate() method:

    Code:
    if(Close[1] < SMA(Close, varSMA)[1] && Position.MarketPosition != MarketPosition.Short) // sygnał do shorta
                {
                    sigPrice = Close[1] - varFilter; // cena zamknięcia z wczoraj minus filtr
                    Print ("Sygnał Short SMA, sigPrice = " + sigPrice);
                    if(Low[0] <= sigPrice && High[0] >= sigPrice) { // cena dziś jest w przedziale low-high ceny sygnału
                      EnterShort(DefaultQuantity, "Open Short"); // otwiera short market order i zamyka wszystkie otwarte longi
                                                                 // TODO: po jakiej cenie otwiera? mnie interesuje cena Closes[0][1] - varFilter
                      //EnterShortLimit(DefaultQuantity, sigPrice, "Open Short Limit");
                    }    
                }

    #2
    Additionaly, SetProfitTarget() doesn't working when I'm using: if(Close[1] < SMA(Close, varSMA)[1]...
    If I use if(CrossAbove(SMA(Close, varSMA),Close,1)... then both order fill and execution dates are ok and profittarget works.

    I hope, that I needn't use CrossAbove() only in NT?
    - because I want trade not only when SMA hits the bar but when it is below or above of close price as well.

    Comment


      #3
      SetProfitTarget() already works - I had bad first parametr (fromEntrySignal)

      Comment


        #4
        Originally posted by Argo1 View Post
        I'm writing my first NT strategy and I've got problem:
        order is filled "today" at 00:00 but executed "next day" at 00:00. Why is not executed the same day?
        This is expected behavior. NinjaTrader can only evaluate one bar at a time, so as soon as your condition is true (on bar 0, for example), it will send in a order to be executed as soon as possible. The next bar (bar 1), the backtester "sees" this order and executes it at the open.

        Originally posted by Argo1 View Post
        Second question: how can I open position not at open price but at open price-20pips? I tried with EnterShortLimit() but position is closing at price out of the bar few days later (at price from one before bar).
        EnterShortLimit() will enter at the price you specify. Something to watch: the default behavior for EnterShortLimit() (and the other similar entry methods) is to cancel the order after one bar if the conditions that caused the entry are no longer true. Make sure your orders aren't being cancelled and resubmitted at an incorrect price.

        Here is a sample for keeping orders alive.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Thanks Austin for your replies.

          Now, I've got another problem: entry order is rejected when I reverse position.

          I use EnterShortLimit() / EnterLongLimit() for opening positions and SetProfitTarget() in Initialize().
          I backtest on daily bars.
          This simple strategy opens only 1 position in one direction, closes only by reversion or profit target.

          But, due to NT limitations described in "Interal Order Handling Rules that Reduce Unwanted Positions" http://www.ninjatrader-support.com/H...tml?Overview36 entry orders are ignored when: "A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction".

          (When I disabled SetProfitTarget() order was filled correctly)

          Output window:
          2008-04-18 00:00:00 Entered internal PlaceOrder() method at 2008-04-18 00:00:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=207,33 StopPrice=0 SignalName='Open Long Limit' FromEntrySignal=''
          2008-04-18 00:00:00 Ignored PlaceOrder() method at 2008-04-18 00:00:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=207,33 StopPrice=0 SignalName=Open Long Limit' FromEntrySignal='' Reason='An Enter() method to submit an entry order has been ignore. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'


          How can I fix this problem?

          Comment


            #6
            I moved this last problem into new thread:

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X