Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PositionUpdate from Addon Approach vs Strategy OnPositionUpdate

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

    PositionUpdate from Addon Approach vs Strategy OnPositionUpdate

    Does the Addon Account callback PositionUpdate have any of the
    Rithmic or IB related issues mentioned in OnExecutionUpdate?

    Is PositionUpdate guaranteed to be called after every ExecutionUpdate?
    Is PositionUpdate guaranteed to be called for all order types?
    (ChartTrader, ATI, OFI, manual, Strategy, ATM, DOM, etc)

    Using the Addon approach, I want to be able to submit orders, and
    also watch for the moment the account position has become flat.

    As far as watching for the Flat event,
    I think PositionUpdate is the best (only?) way to do this, correct?
    Are there any other ways?

    With PositionUpdate, what can I truly rely on?

    Are there any caveats to using PositionUpdate?
    ​That's why I'm asking about the guarantees.

    I mean, I want PositionUpdate to be called every time the
    account position becomes flat (for any given instrument, of
    course) no matter what happened to cause that ... can I
    rely on that guarantee of notification delivery via this
    callback?

    EDIT: I'm not really concerned about the sequence of events,
    I just want to know that for all broker technology adapters, esp
    Rithmic, IB, Continuum, the PositionUpdate callback can be
    reliably used to monitor when the position becomes flat.

    EDIT-2: I'm doing this from an indicator, if that matters.

    Last edited by bltdavid; 03-02-2023, 08:07 PM.

    #2
    Hello bltdavid,

    Yes that would be the same for any tool that uses those events for those brokers. You would have to take the same precautions as a strategy. If you want to use the information from OnPositionUpdate you would need to use the passed in variables as mentioned in the help guide note. The note for OnPositionUpdate also mentions that you should instead use OnExecution if you are trying to drive your logic.

    •Rithmic and Interactive Brokers Users: When using a NinjaScript strategy it is best practice to only work with passed by value data from OnExecution. Instances of multiple fills at the same time for the same instrument might result in an incorrect OnPositionUpdate, as sequence of events are not guaranteed due to provider API design. For an example on protecting positions with this approach, see OnExecutionUpdate()

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Yes that would be the same for any tool that uses those events for those brokers. You would have to take the same precautions as a strategy. If you want to use the information from OnPositionUpdate you would need to use the passed in variables as mentioned in the help guide note. The note for OnPositionUpdate also mentions that you should instead use OnExecution if you are trying to drive your logic.
      The 'passed in variables' comment -- how does that apply to Account's PositionUpdate callback?
      That callback has a PositionEventArgs, which doesn't seem to be documented.

      Looking at the Account callback ExecutionUpdate, the ExecutionEventArgs is also not documented.

      Why are these critical arguments not documented?

      Comment


        #4
        Hello bltdavid,

        Those items are not documented because that is part of the advanced development portion of NinjaScript. A majority of the addon section is not documented and makes the assumption that you are already well versed in C# coding and exploring C# objects using intellepromt/intellesense. There are some specific samples on certain topics but you will find that a lot of items like event arguments or properties in the account/addon are not documented.

        The passed in value in this case would be the PositionEventArgs because no strategy is being used. Strategies have additional passed in values on their overrides because they are virtualized and have their own properties separate from the account. You still need to take the same considerations as a strategy when using the account directly, instead of relying on the values of saved variables to contain the correct current value you would want to use the information that the event is providing through its argument.

        You can find a unmanaged strategy sample in the following forum post that shows one way to work with IB/Rthmic events to help correctly calculate the position information based on the OnOrderUpdate event. Its possible to completely avoid using OnExecution and OnPositonUpdate for these brokers due to how their api sends events. You could do a similar task in an addon to accommodate the out of order events or incorrect position updates in certain cases.

        Hello, I connected to Interactive brokers. My strategy uses OnOrderUpdate, OnExecution, and OnPositionUpdate and my strategy uses orderName as a key for example to identify Enter signalName or exit signalName and other uses. But According to help manual : The problem is that the order name does not passed by value data


        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Those items are not documented because that is part of the advanced development portion of NinjaScript. A majority of the addon section is not documented and makes the assumption that you are already well versed in C# coding and exploring C# objects using intellepromt/intellesense. There are some specific samples on certain topics but you will find that a lot of items like event arguments or properties in the account/addon are not documented.
          Yep, NinjaScript Editor's intellisense has been an invaluable resource.

          Nonetheless, there are plenty of things that should be documented,
          such as this, this, and this.

          It's a real sorry state of affairs for NinjaTrader to expect me to seek
          advanced development information via intellisense, and then when
          there is a question about what I find, you guys can't comment further
          because it's undocumented.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          59 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          134 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          75 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X