Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Execution at a price not in the bar

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

    Execution at a price not in the bar

    The high of the bar is 229.91 and the buy execution is at 235.59'5.

    I've included a screenshot of the chart showing the trade.

    I've included a zip with the tick data for that day. You can see the massive drop at 0459, here's a snippet:

    19980902 045300;236.48;1
    19980902 045400;236.4;1
    19980902 045600;236.27;1
    19980902 045700;236.07;1
    19980902 045900;236.08;1
    19980902 050200;229.64;1
    19980902 050300;229.69;1
    19980902 050500;229.81;1


    Here are the orders:
    $GBPJPY Buy Limit 100000 235.59'5 0 Filled 100000 235.5925883 Go Long Gtc 02/09/1998 05:00
    $GBPJPY Sell Market 100000 0 0 Filled 100000 229.535 exit long @mkt Gtc 02/09/1998 06:00

    and the trade:

    17 $GBPJPY Backtest TrendFollower006 Long 100000 235.5925883 229.535 02/09/1998 06:00 02/09/1998 07:00 Go Long exit long @mkt -6062.588339 -15298.88063 5 6332.588339 0 0 0

    It looks to me as if it's an 'edge' effect because I looked at the minute bars and I can see that NT has calculated the minute bar for 0500 with the price from 0459:

    19980902 045700;236.27;236.27;236.27;236.27;1
    19980902 045800;236.07;236.07;236.07;236.07;1
    19980902 050000;236.08;236.08;236.08;236.08;1
    19980902 050300;229.64;229.64;229.64;229.64;1


    So it's calculated the minute bar with the last price from 0459, and also executed the order at that level, which obviously wrong when it should display an Open using the first tick of the time period. So the 60 min bar that the Chart tab is displaying is correct, but the execution and the 1 minute bar in the tick data export file are wrong.

    In case there's a timezone issue, my machine is set to London/Dublin. The tick data in the file comes from the HDM export function.

    Thanks
    Attached Files
    Last edited by adamus; 05-15-2010, 10:13 AM.

    #2
    If you are using limit orders, this is expected when using Default fill algorithm. You will fill at the limit price. You can try Liberal fill algorithms.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Sorry, Josh, I'm not following you.

      Can you give me the exact specification of the fill rule which explains why a tick from the previous bar is used to fill an order at a price that doesn't occur in the bar it is executed in?

      Comment


        #4
        You can find this code snippet in the fill algorithm in Documents\NinjaTrader 7\bin\Custom\Type\@DefaultFillType.cs
        Code:
        else if (order.OrderType == OrderType.Limit)
                    {
                        // Orders are filled when traded through the limit price not at the limit price
                        double nextLow    = NextLow;
                        double nextHigh = NextHigh;
                        if ((order.OrderAction == Cbi.OrderAction.Buy                    && order.LimitPrice > nextLow + epsilon)
                                || (order.OrderAction == Cbi.OrderAction.BuyToCover    && order.LimitPrice > nextLow + epsilon)
                                || (order.OrderAction == Cbi.OrderAction.Sell            && order.LimitPrice < nextHigh - epsilon)
                                || (order.OrderAction == Cbi.OrderAction.SellShort    && order.LimitPrice < nextHigh - epsilon))
                            FillPrice = order.LimitPrice;                                                // set fill price
                    }
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        592 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X