Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with getting AvgFillPrice

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

    Problem with getting AvgFillPrice

    This code runs correctly in Market Replay, giving me the average fill price, but when run in real time it give me 0 instead of the average fill. Everything else in this strategy works fine.
    Any thoughts about why this is happening and what I might try?

    myEntryStats = EnterShort(DefaultQuantity, "ShortEntry");
    myEntryPrice = myEntryStats.AvgFillPrice;
    Print(Convert.ToString(myEntryStats.AvgFillPrice)) ;

    #2
    Hello,

    Thanks for the forum post.

    Is this reproducible?

    Also, Can you please let me know what version of NinjaTrader you are using this is located in the Control Center under Help->About and is to the right of the NinjaTrader logo.


    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      Ver 7.0 10000.1 (Live)
      I don't know if this is what you meant by reproducible:
      It happened this morning and yesterday when running the strategy live for the first times. I get the fill number on the screen through a DrawTextFixed() statement which also gives me additional info on the trade not dependent on the fill price, i.e., bar open and stop and target data.
      I added the print statement when going to Market Replay to further troubleshoot. Both the print and DrawTextFixed() give me zero for the fill in real time and the correct fill price in replay--the program does make the fill correctly in both.

      Comment


        #4
        Has it happened 100% of the time or only some of the time?

        Also, Who is your broker?

        I look forward to assisting you further.
        BrettNinjaTrader Product Management

        Comment


          #5
          It's happened the two times I ran the strategy in real time. My broker is Interactive Brokers but I've so far only run the strategy in the NT sim. I use IQ Feed for data and range charts.

          Comment


            #6
            Hello,

            Follow the instructions below to repair the NinjaTrader database in this case and let me know if it occurs again.

            • Disconnect NinjaTrader from any open connections via File > Disconnect
            • From the NinjaTrader Control Center window select the menu Tools > Options
            • Select the "Data" tab
            • Press the "Repair DB" button
            • Press the "OK" button
            Restart NinjaTrader and let me know if you're able to get up and running after following those steps.
            BrettNinjaTrader Product Management

            Comment


              #7
              As you sugggested, I repaired the database and re-booted. Ran the program this morning in the IB sim and again I got zero for the average fill. When I ran it in market replay this evening, once again it gave me the correct price for the trade. Is there anything else that I can try? The code works fine in market replay but does not work in your sim or IB's in real time.

              Comment


                #8
                Hello,

                Can you please send me your code this is occuring on as I cannot duplicate on my side currently.

                Please send this to support at ninjatrader dot com and reference this forum post and put ATTN : Brett in the subject line.

                I look forward to assisting you further.
                BrettNinjaTrader Product Management

                Comment


                  #9
                  Hi,
                  You should get zero on the AvgFillPrice. To be in a position after triggering an order takes time. You can not immediately get FillPrice.

                  Baruch

                  Comment


                    #10
                    Baruch,

                    Thanks for posting.

                    This issue was resolved via email. Will post the result here as well for others to benifit.

                    The reason this occurs is that you ask for the AvgFill price right after the EnterShort() command. At this time the order is not filled yet (It is filled instantly on Market Replay) but in real life it takes aa second or so to get filled. Only after it is filled will it have the AvgFillPrice populated.

                    Therefor heres what I recommend. Adding in the following method OnOrderUpdate() and checking this status here.

                    In the example, instead of setting the object back to Null, be sue to output the AvgPrice as will after it is filled and output this price here.

                    http://www.ninjatrader.com/support/helpGuides/nt7/iorder.htm

                    As far as your second question this is more general c# windows programming which I'm unable to provide support on. Suggest using google to find this information.

                    Let me know if I can be of further assistance.
                    BrettNinjaTrader Product Management

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    656 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    371 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    109 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    574 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    579 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X