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

PnL for all strategies/instruments for a day (realized and unrealized)

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

    PnL for all strategies/instruments for a day (realized and unrealized)

    I want to start to run multiple instruments off a strategy. I would like to check the total balance of the realized and unrealized PnL so I can use the total PnL as a stop loss or a take profit signal to halt trading on all strategies and instruments. I can do it just fine on a single instrument but am looking for a snippet of code to look at the account balance rather than the position balance. Any help is appreciated.

    #2
    Hello cpabiz20k,

    Thank you for the post.

    I wanted to clarify, do you mean to gather the PnL for all instruments your strategy uses, or do you mean in a greater scope and literally all strategies you have running?

    If you mean just for this strategy, you could use the Position objects to gather unrealized PnL from any of the open positions it has. You can use the SystemPerformance collection for realized PnL. If you otherwise meant all of the account in total, this is something you would need to access an account directly and use the addon account methods for. https://ninjatrader.com/support/help...ount_class.htm

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

    Comment


      #3
      Thanks for the information. I am looking to find a way for all strategies to be considered. If I have 2 strategies running for the day, when the total daily value hits a certain value in profit or loss, I want to close out all strategies. Seems like there would be a snippet of code somewhere to help with that.

      The reason I am focusing on the account is that I can see the total daily value of all strategies that have been running for the day from the broker. Any additional help is appreciated.

      Comment


        #4
        Hello cpabiz20k,

        Thank you for your reply.

        Yes, in this case, there is not really an existing method specifically for this as this goes against how strategies normally operate. Strategies are generally intended to be isolated so accessing other strategies information is not native to a strategy.

        You could use the addon account methods to pull the overall account values in each strategy and then have each strategy manage its self based on that information.





        If you are only looking for the values from strategies excluding manual trading you would need to have each strategy instance and its trade performance values. The addon account methods can loop over the strategies collection as well:



        With each strategy instance, you could use its normal strategy account reporting methods to retrieve those strategies values.

        These would be a few options on how you could approach this.

        I look forward to being of further assistance.


        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by inanazsocial, Today, 01:15 AM
        0 responses
        2 views
        0 likes
        Last Post inanazsocial  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        22 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Started by guillembm, Yesterday, 11:25 AM
        2 responses
        10 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        71 views
        0 likes
        Last Post jeronymite  
        Working...
        X