Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect Average Price

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

    Incorrect Average Price

    I just started paying for NT so I could use the ATM and OCO functionalities. I've had the same problem twice during the last two days with the average price being reported by NT being wrong.

    I'm using an ATM strategy that has 1 stop level and 1 target level.

    After entering my first contract, I continue to scale in and add contracts at different levels. This updates the quantity of the stop and target orders.

    Then, a couple minutes later, I begin to scale out of my position in a profit using limit orders, which reduces the quantity of the stop and target order values but the ultimate target order is not hit (so I still have a position on).

    Then the market comes back and I add more contracts to my position at better prices. This is where the average price being reported by NT gets screwed up. It displays an average price in both the DOM and the Positions tab of the Control Center that would be true if I had never scaled out any contracts. For example, if I had 5 contracts on before beginning to scale out, then I scale out 3 at a profit (but keep two in the position), then later add 2 more at a better price, the average price reported by NT is doing the math as though I had all 7 contracts, which shows me a worse average price than I really have, since I only have 4 contracts on now.

    Does this make sense? Is there any way to fix this? I trade with a scale-in scale-out approach for one of my strategies but I really like using the ATM functionality to automatically enter and adjust the quantities of my stop and target orders. Please help!

    FYI, the ATM Strategy selection mode is set to "SelectActiveATMStragetyOnOrderSubmission," if that makes a difference.

    #2
    Here's a little additional info:

    For both of the trades in question, NT "missed" some of my exit orders in the Execution tab, and I had to go back and add them manually to the Execution tab using the report from my broker. I don't know if this is directly related to the average entry price problem, because the orders that NT missed were not the initial scale-out orders that reduced my original position size, they were orders that ended up being part of the orders that ultimately exited me from the position.

    Again, I don't know if this is the same or a different problem, but I figured the more info the better.

    Comment


      #3
      Hi filter_sweep,


      What broker technology/data feed are you connected to?



      What instrument are you trading?



      Are there any errors in your log tab?



      Does this happen in both sim and live trading?



      Repair your database and let me know if this helps.



      Please follow the instructions below to repair the NinjaTrader database.

      Disconnect NinjaTrader from any open connections via File > Disconnect
      From the NinjaTrader Control Center window select the menu Tools > Options
      Select the "Misc" tab
      Press the "Repair DB" button
      Press the "OK" button
      MichaelNinjaTrader Customer Service

      Comment


        #4
        Broker/Data: Mirus & ZenFire.

        Instruments I experience this on were FESX and BUND.

        I've never noticed it when playing with the SIM, but I experienced it with a live account.

        I'm not sure if there were any errors in the log, I restarted NT in order to make the ATM strategy realize I wasn't in a position any more (it still said active on the Strategies tab).

        I'll try repairing the database later after I'm done trading.

        Can you answer one question for me though? Can you confirm that the average price problem I am having is not a -feature- of the ATM strategy logic, and that you guys don't think it should be working like that?

        Comment


          #5
          Hi,


          The averaging is expected behavior, please use the instructions provided as this may tailor the settings to your liking.

          Go to tools --> Options --> Check the "Use FIFO for position avg. price calculations".

          Let me know if this helps.
          MichaelNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Michael View Post
            Hi,


            The averaging is expected behavior, please use the instructions provided as this may tailor the settings to your liking.

            Go to tools --> Options --> Check the "Use FIFO for position avg. price calculations".

            Let me know if this helps.
            I'm willing to try that, but could you please explain (maybe with a hypothetical trade example) of how the FIFO option will give me my desired result? The help manual is very brief on the topic.

            I'm having a hard time wrapping my head around this. FIFO obviously means first in, first out. I'm not sure what that has to do with average price though. If I enter one long contract at 92, and another at 80, my average price is now 86. If I exit one of the two in my position at 90, I book a 4 tick profit and now I have 1 contract with an average price of 86. If the market comes back down to 80, and I enter another contract at 80, I now have 2 contracts with an average price of 83. However, without checking the FIFO box, NT is telling me my average price is 84, cause it is calculating with the assumption that I still have all 3 contracts in the position.

            Now if I check the FIFO box, I assume that means it would remove the original contract bought at 92 from the calcluation (first in, first out), so it would average the two contracts bought at 80, and say my average price is 80. However, that's wrong, because my average position price is still actually 83. Am I missing something?
            Last edited by filter_sweep; 03-06-2009, 12:08 PM.

            Comment


              #7
              So I repaired my database and did some testing with the SIM account and confirmed the following:

              1. Checking the "Use FIFO for position avg. price calculations" box does not fix the problem, it just creates a different problem by reporting the wrong average price in a different way.

              2. Even without using an ATM strategy the average price gets reported wrong. Whatever code is calculating the average price does not take into account the current position size when a new contract is added, if any of the contracts in the original position have been exited.

              If this is actually the expected behavior, and not considered to be a bug, do you have any suggestions? I don't have time while trading to manually calculate my average price by hand using a spreadsheet. If it is the expected behavior, could you explain the logic of this? Can I make a suggestion to give us the option of how the average price is calculated (beyond the FIFO thing, which doesn't make much sense anyway)?

              Comment


                #8
                Hi Filter_Sweep,



                Thank you for the suggestion.



                The platform is calculating as expected.



                Please elaborate on what you mean by the logic and what you would prefer to see versus what is occurring.



                The FIFO option means the average entry price is calculated using FIFO optimization, please visit the link provided as there is a thorough explanation here that should clarify.


                MichaelNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Michael View Post
                  Hi Filter_Sweep,



                  Thank you for the suggestion.



                  The platform is calculating as expected.



                  Please elaborate on what you mean by the logic and what you would prefer to see versus what is occurring.



                  The FIFO option means the average entry price is calculated using FIFO optimization, please visit the link provided as there is a thorough explanation here that should clarify.


                  http://www.ninjatrader-support.com/H...helpguide.html
                  I think you're confusing FIFO optimization (which maintains the location of your order in the queue) with the FIFO option for average price calcluations.

                  No matter though, I think I've come to terms that this is just how the software works, and I'll either adjust to it or switch brokers/software. I traded using Interactive Broker's BookTrader for a couple of years and got used to the way IB calculates average prices, but recently switched brokers and started using Ninja for order entry and I'm surprised by the logic.

                  Since you asked, I'll try to articulate what appears to be the logic of NinjaTrader vs. the logic of what I would expect:

                  With NinjaTrader, it appears that from the time a position is entered in one direction (long or short) and until the entire position is flat, it keeps a counter in the background of how many contracts have been entered in that direction, and uses that count (along with all the entry prices) to calculate the average price of the current position, regardless if any contracts were scaled out before scaling in additional contracts. In other words, NinjaTrader doesn't care about reporting the average price relative to the open P&L in the position, it only cares about staying consistent with every contract added since the inception of the position.

                  The way IB calculates average price, and the way I would expect it, is that if you enter two contracts at different prices (like 92 and 80), you now have 2 contracts with an average price of 86. However, if you exit one of those contracts, your new average price is 1 contract at 86 (whereas NinjaTrader is still calculating 2 contracts at 86 for future scale-ins). So if I add another contract to the position at 70, IB calculates and I would expect that my new average price is 78 ((86+70)/2). Instead, NinjaTrader tells me my average price is 80.66 ((92+80+70)/3 or (86+86+70)/3, I'm not sure what actually happens in the background). That's a big difference!

                  See, this makes no sense to me, because from a P&L perspective, when the market is at 79, my true P&L in the open trade is 2 ticks in aggregate (1 tick per contract), but NinjaTrader is telling me I currently have a loss of over 3 ticks in aggregate (2 contracts * 80.66-79). I might end up making a trading decision (like moving my stop to breakeven) based on the average price being reported, and I want to know the true average price as it relates to my open P&L.

                  Put another way, when I scale-in with multiple contracts, and then exit one or more of those contracts (while keeping the position open), in my mind I am booking profits or taking losses on those contracts, and once I exit them they are gone, and whatever is left in the position is my new average price going forward. So I calculate my go-forward open P&L based on the number of contracts I have left times the average price, and if I add more contracts to the position, I want the updated average price to reflect my new open P&L. Instead, it appears NinjaTrader is trying to maintain integrity with the entire position from inception to flat, regardless of the true open P&L. I guess whoever developed the NT application didn't anticipate someone would trade that way (multiple scale-ins and scale-outs within the same position). And the FIFO option does not improve the situation, as it only removes the first-in contracts from the calculation, so instead of showing me a loss when I'm actually in a profit, it will show my I'm in a profit when I'm actually in a loss.

                  To say it as simply as I can, I want the average price to indicate the break-even price for the number contracts that are currently open, but NinjaTrader displays an average price for every contract that has been added to the position since inception, regardless of how many have already been scaled out.

                  If this still doesn't make sense, please let me know and I'll continue to try and explain. I hope you can tell I care about this, because I like NT and really want to be able to use it going forward. However, knowing my true open P&L in a position is important to me because I make decisions based on that info, and I would think that most traders would think the same way.
                  Last edited by filter_sweep; 03-06-2009, 07:01 PM.

                  Comment


                    #10
                    solution

                    I am having the same problem as you but Ninja support doesn't seem to understand the simple math of average-
                    Could you let me know if got yours to work properly.
                    This problem has just started to occur in the last two days I am working is it is contract rollover related in the software

                    Comment


                      #11
                      Originally posted by palmer View Post
                      I am having the same problem as you but Ninja support doesn't seem to understand the simple math of average-
                      Could you let me know if got yours to work properly.
                      This problem has just started to occur in the last two days I am working is it is contract rollover related in the software
                      No, my software still acts the same way, and as stated by one of the support guys earlier in this thread, the way it is calculating average prices is the expected behavior. That's not how I calculate average price, but it must be for whoever wrote the software.

                      Since NT support didn't respond to my last post, I take that to mean they don't think this is an issue worth spending any time on. For the moment I'm using a spreadsheet to calcualte my true average price, but it's a pain in the butt to say the least.

                      On another note, I spoke to my broker (Mirus) and they said that they are currently working on their own software package that should be in beta within a couple of months. If their software calculates average prices like the rest of the free world then I'll probably switch over to their software and discontinue my NT lease.

                      Comment


                        #12
                        Mirus

                        My broker is also Mirus I was not aware they were trying to implement their own software.

                        Comment


                          #13
                          breakeven calculation for a series of trades

                          I hoped that Position.AvgEntry would work for calculating breakeven for a series of trades, but no. Is there an example how to retrieve fill info with the OnExecution() method? Or an easier way to get fill price and quantity?

                          I need to calculate the average of open trade entries, adjusted for partial profits or losses taken, i.e. the break-even point, for a series of trades within a single trend play, for two purposes:

                          1. to evaluate when to allow to add size without taking on more risk than the initial entry

                          2. to calculate a stop-loss based on the break-even point of a series of trades (while the position is being built, a successful play will end later at a trailing stop or profit target)

                          The calculation is the same for long or short:
                          Sum of (entries x trade size) - (exits x trade size) / open trades size

                          long 1 at 100
                          long 1 at 105
                          exit 1 at (108)
                          long 1 at 106
                          ==========
                          Total: 203 divided by 2 open units = breakeven at 101.5
                          (AvgPrice returns 103.67)

                          short 2 at 100 = 200
                          short 1 at 96 = 96
                          exit 2 at 94 = (188)
                          short 2 at 97 = 194
                          =================
                          Total: 302 divided by 3 open units = breakeven at 100.67
                          (AvgPrice returns 98)

                          Comment


                            #14
                            I wonder the same thing....

                            Dave - I flirted with the idea of creating a custom indicator that would display the correct average price, but after researching the methods available to retrieve fill info I came to the conclusion that it could not be done, at least not with my level of programming skills. I wish you luck, and if you figure out how to do it, please let me know!

                            Comment


                              #15
                              Originally posted by dave_b_quickc View Post
                              I hoped that Position.AvgEntry would work for calculating breakeven for a series of trades, but no. Is there an example how to retrieve fill info with the OnExecution() method?
                              Dave, as you may have found out by now, OnExecutionUpdate doesn't seem to get called for an ATM strategy.

                              I was quite disappointed by this.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Rapine Heihei, Today, 08:19 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 08:25 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by f.saeidi, Today, 08:01 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by Rapine Heihei, Today, 07:51 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post Rapine Heihei  
                              Started by frslvr, 04-11-2024, 07:26 AM
                              5 responses
                              98 views
                              1 like
                              Last Post caryc123  
                              Working...
                              X