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

Query account position

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

    Query account position

    Hi there,

    1) I want to query my broker account position for a particular instrument (not the strategy position, the broker account position) ... how do I go about that ?

    2) In the same vein, how do I get the list of all open orders in my broker account ? (again, not the strategy-generated orders, all open orders).

    Thanks in advance
    Dominique

    #2
    Hello Dominique,

    We do not currently have a documented/supported method to query the account to retrieve positions and orders. The strategy methods will only be aware of that particular strategy instance. However it is possible. Here's a hint to get you started

    Code:
    foreach (Account acct in Cbi.Globals.Accounts)
    {
    if (acct.Positions != null)
    {
    PositionCollection positions = acct.Positions;
    foreach (Position pos in positions)
    {
    Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
    }
    }
    MatthewNinjaTrader Product Management

    Comment


      #3
      Getting account position NT7

      Simple situation is that whenever I turn my computer off any restart means that open positions entered by a swing strategy account previously will not be reflected in the strategy on restart. Syncing will simply close positions in the account prematurely.

      I need to be able to read the account.instrument position from within the strategy.
      ideas on this please. It is an important point.Syncing only imposes the strategy position on the Account position... there has to be a way for the strategy position to be determined by the account position.

      I have used the snippet of code below to print to output all posiitons... is it then a case of creating variables based on those outputs? Regards
      Last edited by elliot5; 04-28-2016, 03:21 AM.

      Comment


        #4
        Hello everington_f,

        Thank you for your post.

        Once you have pulled the account positions you can then check them to see what they are and then submit your orders in the strategy to protect or adjust those positions as needed. This would require understanding that the strategy position will likely not match your account position and you would be tracking the account position and adjusting it manually. You would also need to use the Unmanaged Approach in order to achieve this. You can find information on the Unmanaged Approach at the following link: http://ninjatrader.com/support/helpG...d_approach.htm

        Comment


          #5
          Account position / Order status

          Thankyou for your feedback Patrick. With NT8 of course this is no longer an issue. I shall play around with it for NT7 and when I get a result will post it for all. Regards

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Kaledus, Today, 01:29 PM
          0 responses
          3 views
          0 likes
          Last Post Kaledus
          by Kaledus
           
          Started by PaulMohn, Today, 12:36 PM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by yertle, Yesterday, 08:38 AM
          8 responses
          37 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by rdtdale, Today, 01:02 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          3 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X