Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect fill price in case of gap

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

    Incorrect fill price in case of gap

    Hi,

    I have a strategy that once it enters a trade, it opens EnterLongLimit (in case of long) order in a lower price (i.e. averaging).

    The issue is that in case of gap down, the price is being filled with wrong price.

    In the attached example, the entry price is 56.59.
    The EnterLongLimit order is placed with price 55.61, but since there was gap down, then it should have filled with the open price (53.38).

    Btw, I'm running the strategy on NT7.
    I saw another thread that might be related to my issue, but there was no answer there - http://ninjatrader.com/support/forum...ad.php?t=75241

    Thanks,

    Shay
    Attached Files

    #2
    Originally posted by shayhz View Post
    Hi,

    The issue is that in case of gap down, the price is being filled with wrong price.

    In the attached example, the entry price is 56.59.
    The EnterLongLimit order is placed with price 55.61, but since there was gap down, then it should have filled with the open price (53.38).
    Looks plausible here?

    You got a better price than 55.61... You had 204 @ 53.43.. did those fill first?

    Did you buy up the market at that price which caused the upward movement?

    Why should your 255 fill at 53.43? You aren't contesting 204 fill @ 53.43 vs 53.38??

    This was in replay? I wouldn't expect more than any volume that is available at a given price @ time.

    Comment


      #3
      Hi,

      The first order that was filled is 55.61, then 54.52 and then 53.43.
      I got a better price, but it doesn't make sense, because the price was never at this price on that candle.
      I'm running a backtest and it gives me wrong results when there is gap down, so I can't really test my strategy.

      Comment


        #4
        Hello,

        Thank you for the question.

        I wanted to check, is this a single series strategy or are there secondary series as well?

        Would you be able to provide a sample of the logic along with the instrument used for me to further review what may have occurred?

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi,

          It happens on the stock DD on 7/20/2015.
          I'm running the below logic on 1 minute interval (with CalculateOnBarClose = true).
          Every OnBarUpdate I check if it's last 5 minutes of the trading day and if to enter long, if yes, then I send EnterLong order - up to here everything works fine.

          When I receive the event of "OnExecution", I have the following code:
          if ((order.OrderState == OrderState.Filled) || (order.OrderState == OrderState.PartFilled))
          {
          if (order.OrderAction == OrderAction.Buy)
          {
          EnterLongLimit(0,true, Position.Quantity, stopLossPrice); //average down
          }
          }


          What happens is that in my example, the first buy order was filled in 56.59 and then I got "OnExecution", so I placed "EnterLongLimit" to 55.61, but since there was gap down, then I expect the order to be filled with 53.38 (open of the day).

          Comment


            #6
            Hello shayhz,

            Thank you for your response.

            Under Historical Fill Processing, switch from 'Default' to 'Liberal' for the Fill Type. This will then look to the limit price and the next bar's high for the lowest of the two, rather than just the limit price for the fill.

            You can view the code of the Liberal and Default fill types under Documents\NinjaTrader 7\bin\Custom\Type on your PC. The files are @LiberalFillType.cs and @DefaultFillType.cs.

            Comment


              #7
              Thank you very much !
              It solved it the issue

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mindset, 05-06-2023, 09:03 PM
              9 responses
              258 views
              0 likes
              Last Post ender_wiggum  
              Started by Mizzouman1, Today, 07:35 AM
              4 responses
              18 views
              0 likes
              Last Post Mizzouman1  
              Started by philmg, Today, 01:17 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_ChristopherJ  
              Started by cre8able, Today, 01:01 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by manitshah915, Today, 12:59 PM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Erick  
              Working...
              X