Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

When to use Position or PositionAccount?

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

    When to use Position or PositionAccount?

    I've developed an indicator (not a strategy) for trading.
    In the indicator I'm checking for an open position with the account.Positions collection.
    The manual mentions a Positions as well as a PositionsAccount collection, and makes some confusing remarks about the difference.

    https://ninjatrader.com/support/help...ionaccount.htm
    Holds an array of Position objects that represent positions managed by the strategy.
    This property should only be used when your strategy is executing orders against multiple instruments.

    https://ninjatrader.com/support/help...onsaccount.htm
    This property should only be used when your strategy is executing orders against multiple instruments.

    And in the Position help it says:
    https://ninjatrader.com/support/help.../?position.htm
    Represents position related information that pertains to an instance of a strategy.
    Tips:
    •For multi-instrument scripts, please see Positions object which holds an array of all instrument positions managed by the strategy's account
    •For a real-world Account Position, please see PositionAccount.
    And the PositionAccount help says:
    https://ninjatrader.com/support/help...ionaccount.htm
    Represents position related information that pertains to real-world account (live or simulation).
    Tips:
    •For multi-instrument scripts, please see PositionsAccount object which holds an array of all instrument positions managed by the strategy's account
    •For a Strategy Position, please see Position
    My indicator is not a strategy and is working with one instrument.
    Which of these collections should I use for live trading?

    #2
    Hello wjadevries,

    If you are creating an indicator that trades you can essentially ignore the Strategy related content. The two items you linked are for use with Strategies.

    You would not have an equivalent object in an indicator, you would reference the account and then the Positions collection from the account. In that collection you may have multiple position objects. https://ninjatrader.com/support/help...ns_account.htm

    You are still working with Position objects not to be confused with a strategies inherited property "Position" which represents its virtual position. The Position object is a class which has the positions properties.

    The Addon section of the help guide is what you want to reference when doing trading/account related tasks from an indicator: https://ninjatrader.com/support/help...nt8/add_on.htm



    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks.
      one more question:
      the addon section also contains the ChangeOrder method, but I can't use it since it gives unknown method compilation errors in my indicator.
      So I use the addon account.Change method instead.
      Why is the ChangeOrder method not available and what would be the difference?

      Comment


        #4
        Hello wjadevries,

        The ChangeOrder method is under the Strategy section in the help guide and is for managed/unmanaged strategies, you would need to refer to the Addon section and its Account sub category. If you are looking at the left bar in the help guide, expand the NinjaScript > Language Reference > Addon > Account. Under the Account category you will see Change, Submit, Cancel etc..

        When you use an account directly you will always be using the instance of the account. All account related help pages will require that you first find the account like shown in the main example here: https://ninjatrader.com/support/help...ount_class.htm

        Once you have the instance of the account you can issue commands to that account like submitting or changing orders.

        If you run into something which is not being found where you tried to use it, try searching for that in the help guide and go to the page for it. For example going to ChangeOrder's page you can see at the top of the page NinjaScript > Language Reference > Strategy > Order Methods > Managed Approach so that won't apply in this use case based on where it was in the help guide.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Totally clear, thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by POTTER16, Today, 03:31 PM
          0 responses
          4 views
          0 likes
          Last Post POTTER16  
          Started by enricbcn, 05-08-2018, 01:36 AM
          78 responses
          43,512 views
          1 like
          Last Post Wessel
          by Wessel
           
          Started by Wessel, Today, 12:50 PM
          0 responses
          8 views
          0 likes
          Last Post Wessel
          by Wessel
           
          Started by asmmbillah, Today, 12:39 PM
          0 responses
          8 views
          0 likes
          Last Post asmmbillah  
          Started by dtmtradingco, Today, 12:30 PM
          0 responses
          7 views
          0 likes
          Last Post dtmtradingco  
          Working...
          X