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

OnPositionUpdate - problem

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

    OnPositionUpdate - problem

    Hello,

    I am user of interactive brokers.

    I ran the same strategy concurrently on Sim101 account and on TWS paper account .

    I got an executions and my orders are filled in both accounts.
    The problems are:
    1. In Sim101 account the OnPositionUpdate has been called after OnExecutionUpdate immediately
    Buy the IB(TWS) account the OnPositionUpdate has been called after OnExecutionUpdate after 5 minutes.
    why??

    2. When the position closed in Sim101 account the OnPositionUpdate has been called
    but Buy the IB(TWS) account the OnPositionUpdate was not called.

    The TWS application displayed that the position is closed.
    the order tab and the execution tab in NT is OK (I saw the execution)

    The strategy tab shows that the position is open!!

    Sincerely, Kobi


    #2
    Hello levikNT,

    Thank you for your post.

    When running a strategy on an Interactive Brokers account, the strategy position on the accounts tab may not update to reflect that position.

    This is due to the fact Interactive Brokers' order, execution, and positions events do not have a guaranteed order. See the 5th note on this page of our help guide:

    https://ninjatrader.com/support/help...tionupdate.htm

    However, if you print the strategy position in OnBarUpdate it should show the strategy is aware of the position.

    The next release of NinjaTrader should resolve this issue.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello Kate W.

      Thank you for your response.

      Unfortunately you didn't answer my other questions :

      I ran the same strategy concurrently on Sim101 account and on TWS paper account .

      I got executions and my orders were filled in both accounts.
      The problems are:
      1. In Sim101 account the OnPositionUpdate has been called after OnExecutionUpdate immediately
      Buy the IB(TWS) account the OnPositionUpdate has been called after OnExecutionUpdate after 5 minutes.
      why??

      2. When the position closed in Sim101 account the OnPositionUpdate has been called
      but Buy the IB(TWS) account the OnPositionUpdate was not called.

      Sincerely, Kobi




      Comment


        #4
        Hello levikNT,

        Thank you for your reply.

        As I mentioned in my previous reply, with Interactive Brokers the order that OnOrderUpdate, OnExecutionUpdate, and OnPositionUpdate occur in is not guaranteed. This means that you may not see a position or execution update when you would normally expect.

        It is possible to do your own position tracking within the strategy to better track position with Interactive Brokers.

        I'm attaching an example Unmanaged strategy that demonstrates how to track position in a script.

        Again, this behavior with Interactive Brokers is scheduled for improvement in the next release of the platform.

        Please let us know if we may be of further assistance to you.
        Attached Files
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hello Kate W.,

          My core strategy is already written based on Manage approach.

          Should I wait for the next improvement in the release of the platform regarding to this behavior with Interactive Brokers?
          Will the next release completely solve this issue with IB?

          Sincerely, Kobi

          Comment


            #6
            Hello levikNT,

            Thank you for your reply.

            I do know that improvements will be in the new version, but I would expect that you would still see some out of order execution/order/position updates. You can certainly modify the provided example to use Managed orders instead and track the position.

            I have added a vote for you to a current feature request to further improve the order in which order/position/execution updates occur. This may be tracked under the number SFT-3805.

            As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

            Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

            Please let us know if we may be of further assistance to you.

            ​​​​​​​
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Hello Kate W.

              1. will this designing based on the example that you sent me use OnOrderUpdate only, and create its own Position object to track the strategy position.
              will affect the Tarde performance tool using manage approach or unmanage approach?

              2. I am a little bit confused you said that I can use the manage approach but According to NinjaTrader_Jim (NinjaTrader Customer Service) post I should use only the unmanage approach!!

              Since the Managed Approach is tied to the Strategy Position and that is updated in OnExecutionUpdate, we need to decouple ourselves from the internal strategy position and make our own using OrderUpdates instead. Making our own Position object based on OrderUpdates gives us a Position object to use, and using the Unmanaged Approach decouples us from the built in Strategy Position object.
              If you use the Managed Approach, your order submissions are going to be limited to what is currently seen for the strategy's built in Position object. You need to use Unmanaged to break away from that. Since the strategy Position object is based on ExecutionUpdates and your logic is going to focus on OnOrderUpdate, then you can still hit some of the same issues involving order/execution/position ordering and what the strategy sees as its current position. Using the Unmanaged Approach would be needed.
              Sincerely, Kobi



              Comment


                #8
                Hello levikNT,

                Thank you for your reply.

                I would like to correct that, after conferring with my colleagues you would have to use the unmanaged approach to track your position, as I neglected to think about the managed approach's internal handling rules that are built in based on the Strategy position object.

                As far as whether this would affect Trade Perfomance, no. Trades are paired Entry - Exit first in/first out so the position of the strategy doesn't affect that pairing.

                Please let us know if we may be of further assistance to you.
                Kate W.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by f.saeidi, Today, 12:14 PM
                7 responses
                14 views
                0 likes
                Last Post f.saeidi  
                Started by Russ Moreland, Today, 12:54 PM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by philmg, Today, 12:55 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by TradeForge, 04-19-2024, 02:09 AM
                2 responses
                32 views
                0 likes
                Last Post TradeForge  
                Started by aprilfool, 12-03-2022, 03:01 PM
                3 responses
                329 views
                0 likes
                Last Post NinjaTrader_Adrian  
                Working...
                X