• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.

    https://ninjatrader.com/support/help...sitionsaccount

    https://ninjatrader.com/support/help...ionaccount.htm

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

    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); // is this for Sim102?
                  }

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

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

      Code:
      double Profit =
                      (
                      PositionsAccount[0].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) // is this Sim102?
                       +
                      PositionsAccount[1].GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) // and this is Sim101?
                      );
      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/help...ns_account.htm
        https://ninjatrader.com/support/helpGuides/nt8/en-us/account_class.htm



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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ketotop7, Today, 03:58 AM
        0 responses
        4 views
        0 likes
        Last Post ketotop7  
        Started by Radiant0, Today, 03:55 AM
        0 responses
        3 views
        0 likes
        Last Post Radiant0  
        Started by pstrusi, Today, 02:21 AM
        0 responses
        4 views
        0 likes
        Last Post pstrusi
        by pstrusi
         
        Started by indy73, Yesterday, 10:52 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_EricB  
        Started by priceisking, 05-13-2019, 08:30 AM
        6 responses
        39 views
        0 likes
        Last Post Harry
        by Harry
         
        Working...
        X