Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetUnrealizedProfitLoss() of another account

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

    GetUnrealizedProfitLoss() of another account

    Strategy A is running on account Sim101 and
    Strategy B is running on account Sim102

    Can Strategy A GetUnrealizedProfitLoss()
    of Sim102?

    #2
    Hello johnnybegoode,

    You can use the PositionsAccount object to find account positions. With a PositionAccount object, you can then use the standard GetUnrealizedProfitLoss() to get PnL.





    I look forward to being of further assistance.

    Comment


      #3
      I would like to get a total of the Unrealized PnL
      of Sim101 and Sim102,

      Strategy A is buying EUR/USD on Sim101 account and
      Strategy B is selling EUR/USD on Sim102 account.

      Does this look right?
      I keep getting the DB error (attached)

      Strategy A is enabled on Account Sim101
      Code:
      else if (State == State.Configure)
                  {
                      AddDataSeries("EURUSD", Data.BarsPeriodType.Second, 1, Data.MarketDataType.Last);[B] // is this for Sim102?[/B]
                  }

      Code:
      double Profit =
                      (
                      PositionsAccount[0].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) // [B]is this Sim101?[/B]
                       +
                      PositionsAccount[1].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) // [B]and this is Sim102?[/B]
                      );

      Strategy B is enabled on Account Sim102
      Code:
      else if (State == State.Configure)
                  {
                      AddDataSeries("EURUSD", Data.BarsPeriodType.Second, 1, Data.MarketDataType.Last); [B]// is this for Sim101?[/B]
                  }

      Code:
      double Profit =
                      (
                      PositionsAccount[0].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) // [B]is this Sim102?[/B]
                       +
                      PositionsAccount[1].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) // [B]and this is Sim101?[/B]
                      );
      Attached Files
      Last edited by johnnybegoode; 04-03-2019, 10:18 PM.

      Comment


        #4
        Hello johnnybegoode,

        Thank you for your reply.

        What you provided would not be correct, a strategy can only reference a single account at once. What you are asking for would require using the addon account methods to locate the second account. Your strategy and its properties will only reference the account you applied it to when you enabled it. Strategies are really not intended to access any values besides their own, they are intended to be isolated so all properties and methods a strategy has will only apply to what it has done its self and the account it selected.

        You could use the addon account methods to pull the overall account values from an account.

        https://ninjatrader.com/support/helpGuides/nt8/en-us/?get.htm

        https://ninjatrader.com/support/helpGuides/nt8/en-us/account_class.htm



        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        52 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        48 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X