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

Understanding fill price

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

    Understanding fill price

    I am back testing a strategy and am using EnterLong on the next bar. I am using the Default fill type. Most of the time I get a fill price that is at or near the Open on the next bar. However, I often get a fill price that is significantly outside the OHLC for the next bar. I have detected this condition in OnExecution() and print the fill price and OHLC. For example,

    VV Default7/13/2009 bad fill price 40.97 OHLC: 39.99 40.84 39.68 40.83

    Is this behavior expected? I did not expect to get a price out of the range of the next bar.

    I have tried using Liberal Fill and changing the session template to US Equities RTH, but the behavior does not change.

    The differences substantially change the results of my backtest.

    I would appreciate any information you can give me.

    Thanks

    #2
    rocketman,

    I have heard of this before, however its not common. Could you possibly post your strategy code so I may test on my end?:
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      I would prefer not, I have too much effort invested. I can intercept when it happens in OnExecution(), but by that time, execution.Order.AvgFillPrice is already set and is read only. I keep track of a more reasonable price (Open) on my own, but NinjaTrader's summary is entirely different from my statistics. Is there some way I can intercept the fill price and check it prior to it becoming read only?

      Comment


        #4
        Rocketman,

        Was this order placed after having other orders or was it an order by itself?

        Is this a multi-instrument or multi-timeframe strategy?

        Please note that backtesting occurs assuming Calculate on bar close = true, so this may explain your issue. Do the orders that are placed match up with price values in the prior bar?

        There is no supported way to change the AvgFillPrice value.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Single instrument, single time frame

          I am back testing on a collection of instruments, but the strategy is single instrument, daily bars. I collect information in a string series, and use a lock in the OnTermination() to make the output thread safe and produce contiguous output for a single instrument.

          I have added OHLC[1] to my print. the fill price is outside both daily ranges
          Last edited by rocketman75; 03-19-2012, 08:18 AM.

          Comment


            #6
            rocketman,

            Thanks for your note. Unfortunately without a test case here its hard for me to comment further. If you can come up with a toy example that does this and post it would help me in identifying the issue.

            We don't share your strategy code so you can always send it to support at ninjatrader dot com for privacy along with a description of your issue.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Sample code

              I just emailed a strategy and the indicator that it uses to support with Adam P. referenced in the body.

              I run it with default parameters for DIA from 1/1/2007 to present.

              Here is the output I get:

              DIA Default9/18/2007 bad fill price 138.19 OHLC: 134.69 137.48 134.41 137.35 OHLC[1]: 134.12 134.59 133.69 134.06
              DIA Default11/29/2007 bad fill price 134.52 OHLC: 132.49 133.48 132.18 133.17 OHLC[1]: 130.48 133.25 130.41 132.83
              DIA Default3/12/2009 bad fill price 72.19 OHLC: 69.38 71.99 68.85 71.77 OHLC[1]: 69.69 70.32 68.82 69.48
              DIA Default6/29/2011 bad fill price 122.9 OHLC: 122 122.61 121.49 122.45 OHLC[1]: 120.63 121.65 120.49 121.61
              DIA Default3/13/2012 bad fill price 131.79 OHLC: 130.05 131.77 129.85 131.68 OHLC[1]: 129.17 129.67 129.1 129.46
              >>>>>>>>>> DIA Default 9/18/2007 ENTER LONG: quantity 1557 ATR 1.92632587364685
              >>>>>>>>>> DIA Default 9/18/2007 Long Trade: quantity 1557 ATR 1.92632587364685 LongStopPrice 134.337348252706 fill: 138.19 Cost 215161.83
              >>>>>>>>>> DIA Default 9/18/2007 10/17/2007 EXITING LONG TRADE: quantity 1557 ATR 1.92632587364685 LongStopPrice 134.337348252706 fill: 138.19 Cost 215161.83 ExitPrice 138.53 Close 139.16 profit 5978.88 account 305978.88

              >>>>>>>>>> DIA Default 11/29/2007 ENTER LONG: quantity 1423 ATR 2.14974958921011
              >>>>>>>>>> DIA Default 11/29/2007 Long Trade: quantity 1423 ATR 2.14974958921011 LongStopPrice 130.22050082158 fill: 134.52 Cost 191421.96
              >>>>>>>>>> DIA Default 11/29/2007 12/14/2007 EXITING LONG TRADE: quantity 1423 ATR 2.14974958921011 LongStopPrice 130.22050082158 fill: 134.52 Cost 191421.96 ExitPrice 132.99 Close 133.45 profit 711.5 account 306690.38

              >>>>>>>>>> DIA Default 2/1/2008 ENTER LONG: quantity 1188 ATR 2.58113103314046
              >>>>>>>>>> DIA Default 2/1/2008 Long Trade: quantity 1188 ATR 2.58113103314046 LongStopPrice 122.047737933719 fill: 127.21 Cost 151125.48
              >>>>>>>>>> DIA Default 2/1/2008 2/6/2008 EXITING LONG TRADE: quantity 1188 ATR 2.58113103314046 LongStopPrice 122.047737933719 fill: 127.21 Cost 151125.48 ExitPrice 121.6 Close 122.26 profit -6664.68 account 300025.7

              >>>>>>>>>> DIA Default 3/24/2008 ENTER LONG: quantity 1117 ATR 2.68586841027061
              >>>>>>>>>> DIA Default 3/24/2008 Long Trade: quantity 1117 ATR 2.68586841027061 LongStopPrice 120.018263179459 fill: 125.39 Cost 140060.63
              >>>>>>>>>> DIA Default 3/24/2008 4/14/2008 EXITING LONG TRADE: quantity 1117 ATR 2.68586841027061 LongStopPrice 120.018263179459 fill: 125.39 Cost 140060.63 ExitPrice 123.75 Close 123.17 profit -1831.89 account 298193.81

              >>>>>>>>>> DIA Default 7/17/2008 ENTER LONG: quantity 1412 ATR 2.12457224254437
              >>>>>>>>>> DIA Default 7/17/2008 Long Trade: quantity 1412 ATR 2.12457224254437 LongStopPrice 110.350855514911 fill: 114.6 Cost 161815.2
              >>>>>>>>>> DIA Default 7/17/2008 7/28/2008 EXITING LONG TRADE: quantity 1412 ATR 2.12457224254437 LongStopPrice 110.350855514911 fill: 114.6 Cost 161815.2 ExitPrice 111.6 Close 111.34 profit -4236 account 293957.81

              >>>>>>>>>> DIA Default 11/4/2008 ENTER LONG: quantity 585 ATR 5.13078575687325
              >>>>>>>>>> DIA Default 11/4/2008 Long Trade: quantity 585 ATR 5.13078575687325 LongStopPrice 84.7284284862535 fill: 94.99 Cost 55569.15
              >>>>>>>>>> DIA Default 11/4/2008 11/12/2008 EXITING LONG TRADE: quantity 585 ATR 5.13078575687325 LongStopPrice 84.7284284862535 fill: 94.99 Cost 55569.15 ExitPrice 83.57 Close 83.09 profit -6680.71 account 287277.1

              >>>>>>>>>> DIA Default 11/28/2008 ENTER LONG: quantity 623 ATR 4.81349069431886
              >>>>>>>>>> DIA Default 11/28/2008 Long Trade: quantity 623 ATR 4.81349069431886 LongStopPrice 76.6730186113623 fill: 86.3 Cost 53764.9
              >>>>>>>>>> DIA Default 11/28/2008 1/12/2009 EXITING LONG TRADE: quantity 623 ATR 4.81349069431886 LongStopPrice 76.6730186113623 fill: 86.3 Cost 53764.9 ExitPrice 84.61 Close 84.79 profit -1052.87 account 286224.23

              >>>>>>>>>> DIA Default 3/12/2009 ENTER LONG: quantity 1197 ATR 2.50540034303171
              >>>>>>>>>> DIA Default 3/12/2009 Long Trade: quantity 1197 ATR 2.50540034303171 LongStopPrice 67.1791993139366 fill: 72.19 Cost 86411.43
              >>>>>>>>>> DIA Default 3/12/2009 4/14/2009 EXITING LONG TRADE: quantity 1197 ATR 2.50540034303171 LongStopPrice 67.1791993139366 fill: 72.19 Cost 86411.43 ExitPrice 79.04 Close 79.27 profit 11563.02 account 297787.25

              >>>>>>>>>> DIA Default 5/4/2009 ENTER LONG: quantity 1464 ATR 2.04907414456896
              >>>>>>>>>> DIA Default 5/4/2009 Long Trade: quantity 1464 ATR 2.04907414456896 LongStopPrice 79.9618517108621 fill: 84.06 Cost 123063.84
              >>>>>>>>>> DIA Default 5/4/2009 5/21/2009 EXITING LONG TRADE: quantity 1464 ATR 2.04907414456896 LongStopPrice 79.9618517108621 fill: 84.06 Cost 123063.84 ExitPrice 83.42 Close 83.1 profit -936.97 account 296850.28

              >>>>>>>>>> DIA Default 6/2/2009 ENTER LONG: quantity 1625 ATR 1.8460696536743
              >>>>>>>>>> DIA Default 6/2/2009 Long Trade: quantity 1625 ATR 1.8460696536743 LongStopPrice 83.3278606926514 fill: 87.02 Cost 141407.5
              >>>>>>>>>> DIA Default 6/2/2009 6/17/2009 EXITING LONG TRADE: quantity 1625 ATR 1.8460696536743 LongStopPrice 83.3278606926514 fill: 87.02 Cost 141407.5 ExitPrice 85.28 Close 85.23 profit -2827.5 account 294022.78

              >>>>>>>>>> DIA Default 7/15/2009 ENTER LONG: quantity 1941 ATR 1.54534694003399
              >>>>>>>>>> DIA Default 7/15/2009 Long Trade: quantity 1941 ATR 1.54534694003399 LongStopPrice 83.019306119932 fill: 86.11 Cost 167139.51
              >>>>>>>>>> DIA Default 7/15/2009 8/11/2009 EXITING LONG TRADE: quantity 1941 ATR 1.54534694003399 LongStopPrice 83.019306119932 fill: 86.11 Cost 167139.51 ExitPrice 92.55 Close 92.58 profit 12500.03 account 306522.81

              >>>>>>>>>> DIA Default 11/9/2009 ENTER LONG: quantity 2043 ATR 1.50017517207847
              >>>>>>>>>> DIA Default 11/9/2009 Long Trade: quantity 2043 ATR 1.50017517207847 LongStopPrice 99.2696496558431 fill: 102.27 Cost 208937.61
              >>>>>>>>>> DIA Default 11/9/2009 12/8/2009 EXITING LONG TRADE: quantity 2043 ATR 1.50017517207847 LongStopPrice 99.2696496558431 fill: 102.27 Cost 208937.61 ExitPrice 102.96 Close 102.94 profit 1409.66 account 307932.47

              >>>>>>>>>> DIA Default 4/14/2010 ENTER LONG: quantity 3263 ATR 0.943766019645907
              >>>>>>>>>> DIA Default 4/14/2010 Long Trade: quantity 3263 ATR 0.943766019645907 LongStopPrice 109.192467960708 fill: 111.08 Cost 362454.04
              >>>>>>>>>> DIA Default 4/14/2010 4/27/2010 EXITING LONG TRADE: quantity 3263 ATR 0.943766019645907 LongStopPrice 109.192467960708 fill: 111.08 Cost 362454.04 ExitPrice 110.38 Close 109.87 profit -2284.11 account 305648.36

              >>>>>>>>>> DIA Default 6/15/2010 ENTER LONG: quantity 1455 ATR 2.10023601762271
              >>>>>>>>>> DIA Default 6/15/2010 Long Trade: quantity 1455 ATR 2.10023601762271 LongStopPrice 99.4895279647546 fill: 103.69 Cost 150868.95
              >>>>>>>>>> DIA Default 6/15/2010 6/24/2010 EXITING LONG TRADE: quantity 1455 ATR 2.10023601762271 LongStopPrice 99.4895279647546 fill: 103.69 Cost 150868.95 ExitPrice 101.8 Close 101.56 profit -2749.96 account 302898.4

              >>>>>>>>>> DIA Default 11/4/2010 ENTER LONG: quantity 2332 ATR 1.2988536558651
              >>>>>>>>>> DIA Default 11/4/2010 Long Trade: quantity 2332 ATR 1.2988536558651 LongStopPrice 111.85229268827 fill: 114.45 Cost 266897.4
              >>>>>>>>>> DIA Default 11/4/2010 11/12/2010 EXITING LONG TRADE: quantity 2332 ATR 1.2988536558651 LongStopPrice 111.85229268827 fill: 114.45 Cost 266897.4 ExitPrice 112.32 Close 112.16 profit -4967.17 account 297931.23

              >>>>>>>>>> DIA Default 1/18/2011 ENTER LONG: quantity 3363 ATR 0.89205417202778
              >>>>>>>>>> DIA Default 1/18/2011 Long Trade: quantity 3363 ATR 0.89205417202778 LongStopPrice 116.565891655944 fill: 118.35 Cost 398011.05
              >>>>>>>>>> DIA Default 1/18/2011 2/22/2011 EXITING LONG TRADE: quantity 3363 ATR 0.89205417202778 LongStopPrice 116.565891655944 fill: 118.35 Cost 398011.05 ExitPrice 121.67 Close 121.89 profit 11165.16 account 309096.39

              >>>>>>>>>> DIA Default 4/27/2011 ENTER LONG: quantity 2530 ATR 1.22188462940173
              >>>>>>>>>> DIA Default 4/27/2011 Long Trade: quantity 2530 ATR 1.22188462940173 LongStopPrice 124.116230741197 fill: 126.56 Cost 320196.8
              >>>>>>>>>> DIA Default 4/27/2011 5/13/2011 EXITING LONG TRADE: quantity 2530 ATR 1.22188462940173 LongStopPrice 124.116230741197 fill: 126.56 Cost 320196.8 ExitPrice 125.57 Close 125.96 profit -2504.71 account 306591.68

              >>>>>>>>>> DIA Default 6/29/2011 ENTER LONG: quantity 2225 ATR 1.37790838371008
              >>>>>>>>>> DIA Default 6/29/2011 Long Trade: quantity 2225 ATR 1.37790838371008 LongStopPrice 120.14418323258 fill: 122.9 Cost 273452.5
              >>>>>>>>>> DIA Default 6/29/2011 7/18/2011 EXITING LONG TRADE: quantity 2225 ATR 1.37790838371008 LongStopPrice 120.14418323258 fill: 122.9 Cost 273452.5 ExitPrice 124.4 Close 123.62 profit 5340 account 311931.68

              >>>>>>>>>> DIA Default 10/10/2011 ENTER LONG: quantity 1122 ATR 2.7793294930848
              >>>>>>>>>> DIA Default 10/10/2011 Long Trade: quantity 1122 ATR 2.7793294930848 LongStopPrice 108.06134101383 fill: 113.62 Cost 127481.64
              >>>>>>>>>> DIA Default 10/10/2011 11/1/2011 EXITING LONG TRADE: quantity 1122 ATR 2.7793294930848 LongStopPrice 108.06134101383 fill: 113.62 Cost 127481.64 ExitPrice 117.8 Close 116.38 profit 4689.95 account 316621.63

              >>>>>>>>>> DIA Default 3/13/2012 ENTER LONG: quantity 2678 ATR 1.18250941676353
              >>>>>>>>>> DIA Default 3/13/2012 Long Trade: quantity 2678 ATR 1.18250941676353 LongStopPrice 129.424981166473 fill: 131.79 Cost 352933.62
              >>>>>>>>>> DIA Default 3/13/2012 In market long: 3/15/2012 quantity 2678 ATR 1.18250941676353 LongStopPrice 129.424981166473 fill: 131.79 Cost 352933.62 ExitPrice 132.05 Close 132.41 profit 5356 account 321977.63


              Thanks for your help

              Comment


                #8
                rocketman,

                I didn't get the email yet. What is your name or email address? Could you try sending again?
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  [email protected]

                  I resent the support message with the following subject

                  Understanding fill price for Adam P.
                  Last edited by rocketman75; 03-19-2012, 02:29 PM. Reason: adding info

                  Comment


                    #10
                    rocketman,

                    Please resubmit to support at ninjatrader dot com. I am currently unable to find the ticket. Was the message rejected when you look at your email?
                    Adam P.NinjaTrader Customer Service

                    Comment


                      #11
                      I just resent via gmail. I realized what I was doing wrong. I should be there now.

                      Comment


                        #12
                        Just got the reply from support.

                        Comment


                          #13
                          rocketman,

                          I am reviewing now. I did receive the files and request.
                          Adam P.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Mestor, 03-10-2023, 01:50 AM
                          16 responses
                          388 views
                          0 likes
                          Last Post z.franck  
                          Started by rtwave, 04-12-2024, 09:30 AM
                          4 responses
                          31 views
                          0 likes
                          Last Post rtwave
                          by rtwave
                           
                          Started by yertle, Yesterday, 08:38 AM
                          7 responses
                          29 views
                          0 likes
                          Last Post yertle
                          by yertle
                           
                          Started by bmartz, 03-12-2024, 06:12 AM
                          2 responses
                          22 views
                          0 likes
                          Last Post bmartz
                          by bmartz
                           
                          Started by funk10101, Today, 12:02 AM
                          0 responses
                          7 views
                          0 likes
                          Last Post funk10101  
                          Working...
                          X