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

List all Instruments with open positions

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

    List all Instruments with open positions

    It may already be in the forum or help guide but I must not be searching for the right phrase on this.

    I have a strategy that doesn't buy/sell anything but instead runs on minute bars and sends me SMS messages at market open and then on the hour for RTHs afterwards. The main buy/sell strategy always runs on a list of instruments so the status strategy sends overall account info such as net liquidation, realized PnL, Unrealized PnL, and etc. I'm looking to refine this status message with a summation of all negative unrealized PnL positions with a count as well as a summation of all positive unrealized PnL positions with a count.
    Ex:
    Unrealized Profits $100 in 14 Instruments
    Unrealized Losses $50 in 10 Instruments

    What can I use in the status strategy that would give me possibly an array of instruments currently held by the account?

    With that list I should be able to lookup each of those instruments to tally my information.

    Thanks,

    #2
    Hello antrux,

    Thanks for your post.

    You may use the Account.Positions collection to loop through all open positions on the account. The Position's UnRealized PnL can be calculated from the Position.GetUnrealizedPnL() and then you can sort your instruments to either be placed in a new collection for positive and negative PnL or in your own way to sort and present this information. The Position object will also let you know the Instrument of the position with the Position's Instrument object.

    Account.Positions - https://ninjatrader.com/support/help...ns_account.htm

    Position.GetUnRealizedPnL() - https://ninjatrader.com/support/help...profitloss.htm

    Position - https://ninjatrader.com/support/help...s/position.htm

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DJ888, 04-16-2024, 06:09 PM
    5 responses
    14 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by samish18, Yesterday, 08:31 AM
    4 responses
    14 views
    0 likes
    Last Post elirion
    by elirion
     
    Started by funk10101, Yesterday, 09:43 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by TheWhiteDragon, 01-21-2019, 12:44 PM
    5 responses
    551 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by rtwave, 04-12-2024, 09:30 AM
    5 responses
    37 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X