Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Fill price for Limit Orders using Granular technique for creating orders.

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

    Fill price for Limit Orders using Granular technique for creating orders.

    To be able to fill market orders using intra-bar price action for historical data, I am using the technique outline in the “Backtesting NinjaScript Strategies with an intraday granularity” (https://ninjatrader.com/support/help..._frame_and.htm). This logic is working correctly when working with Market orders (EnterLong and EnterShort). I have created two additional data series; one with 1 tick ASK the other with the 1 tick BID. If going Long, I use the ASK data series and for Short I use BID data series. Market orders are working without any issues.

    Now I have the need to enter using Limit order so that I can enter on a pullback after I have the entry signal (this is coming in the primary data series) . I am still using the same technique as before, the granularity one. Now that I am working with Limit orders, I would expect the fill price to be the same as the price in Limit order. I am assuming that because my limit order was entered using a granular technique, that the fill for such an order would be evaluating the granular data series, and generating a fill order with that limit order price.

    After many hours (going into days) of testing, I notice that the fill price for the limit orders is somewhat random. Sometimes I get the Limit price and sometimes I get one tick above the limit price (for long orders).

    Questions:
    1. Based on the strategy that I am sharing (simplified strategy to see if I can understand the fill engine logic) and the fact that I am using the granular entry technique when creating the Limit order, what else should I be doing in order for the fill to be using the granular data series (I have 1 tick ASK, BID and LAST) on the Limit order?
    2. Should I be using the GetCurrentBid or GetCurrentAsk instead of my granular data series?
    3. Do you have an explanation for this behavior?

    Other things that I have tried:
    1. In the strategy that I am sharing, I have tried playing around with the barsInProgressIndex parameter for the EnterLongLimit overload method. At the same time I have use Closes[1][0], Closes[2][0] and Closes[3][0] when calculating the limitPrice. This gives me even more random fill prices.
    Other Observations:

    When it comes to the stop order and the profit target (for simplification purposes I am using the SetProfitTarget() {this order should be a ExitLongLimit order} and the SetStopLos() orders, but eventually I will create those in the OnExecutionUpdate method), the fill price is the one that one would expect. Something is going on with Limit orders and their filled price
    Attached Files

    #2
    Hello GARZONJ,

    Thank you for your post.

    There is no guarantee that a limit order will fill or that if it fills that it will do so at an exact price - simply that if it does fill that it will fill at your limit price or better. Given that with a long order a price of one tick above would be worse, something would be amiss if that's truly the case. However, I would need more information to understand what may be occurring with your orders. I will need to take a look at your log and trace files to see what occurred.

    Since those contain identifying information we'll want you to send those in rather than post them on the forums.
    Please send me your log and trace files so that I may look into what occurred.

    You can do this by going to the Control Center-> Help-> Email Support

    Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

    Please reference the following ticket number in the body of the email: 2350841 ATTN Kate W.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Kate,

      After reading your post and in an attempt to collect more data in the log and trace files, I have found the solution for the issue.

      Issue or behavior:
      • When submitting a Long Limit Order to enter a position (like a pullback x ticks from the triggering bar) using the granular technique, I was not getting a fill when the price reached the limit price. I would use a secondary chart where I would plot the granular data series (ASK,BID, LAST in 1 tick increments) along with the primary and I could see the Limit price being reached by the ASK, BID and LAST data series.
      • I am using my personal Renko bar type which I thought was the problem.
        • My Renko bars uses two parameters, the Brick size and the Threshold value. The Threshold value allows me to control where the NEXT brick begins in respect to the current one.
      Observations:
      • After developing more my test strategy to see order details I discover the following:
        • When using a granular data series such as 1 tick LAST, it forces/utilizes a fill process for historical data which is based on the granular data series. The granular data series is what forces the intra-bar evaluation of the primary data series.
        • When using Limit orders, the fill will ONLY occur if the price reaches the Limit price by one tick or more.
          • In the case of a Long Limit using the ES at Limit Price 3144.00, the order will not be filled unless the prices of the granular data series reached 3144.25. If the price gets to 3144.00, it would not execute the limit order.
            • This logic makes sense since the Limit Price touch does not guarantee that the order would be filled. If the Limit price is surpassed by one tick, only then one can guarantee that the order will be filled at the Limit Price.
        • All Limit Orders get filled at the Limit Price ONLY when the price reaches the Limit Price by at least one tick. It will never fill at a better price when working with historical data.
        • Although I have a data series of 1 tick LAST, I am not using it when submitting my Limit Order
          • This is the Order command: EnterLongLimit(0, true, 1, Close[0] - pullbackInTicks * TickSize, tempoString);
      Hopefully the information above can help anyone that is trying to understand how historical Limit Orders get filled when using granular technique.

      Kate, if anything is incorrect, please let me know.
      Thanks,
      Last edited by GARZONJ; 01-30-2020, 11:50 AM.

      Comment


        #4
        Hello GARZONJ,

        Thank you for your reply.

        Generally limit orders would need to trade through the limit price to be triggered. Out of curiosity, if you turn on Fill Limit Orders on Touch in the Backtest properties, does it fill at the expected price?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Kate,

          You assumption is correct. If you enable the "Fill Limit Orders on Touch" strategy parameter, then the limit orders will be filled if the price touches the limit price.

          Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Max238, Today, 01:28 AM
          2 responses
          26 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Started by Shansen, 08-30-2019, 10:18 PM
          25 responses
          949 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by JonesJoker, 04-22-2024, 12:23 PM
          8 responses
          41 views
          0 likes
          Last Post JonesJoker  
          Started by timko, Today, 06:45 AM
          0 responses
          5 views
          0 likes
          Last Post timko
          by timko
           
          Started by Waxavi, 04-19-2024, 02:10 AM
          2 responses
          41 views
          0 likes
          Last Post poeds
          by poeds
           
          Working...
          X