Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What is the difference between AccountItem and Position Profit and Loss

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

    What is the difference between AccountItem and Position Profit and Loss

    Regarding AccountItem.RealizedProfitLoss and Position.GetUnrealizedProfitLoss

    I am trying to write the logic to stop trading when I hit my daily profit or daily loss. The issue is with Managed Approach if I am in a position, say short, and I get a reversal to a long I can't get an accurate read just from the Account because the position has not gone flat yet. I added these two together and got a "sort of" accurate read for a daily total but it is still an approximation.

    How and when should we use the Account and Position data?

    Thanks.

    #2
    Hello cashinvestor,

    Thanks for your post.

    Can you clarify if you are looking for just the strategies Realized PNL value or the overall account value?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      yes, both. I'm not clear on how to distinguish between the two and how to identify the pnl for a specific strategy versus all the running strategies together.

      Comment


        #4
        Hello cashinvestor,

        Thanks for your reply.

        The strategies UnrealizedPNL through: Position.GetUnrealizedProfitLoss(PerformanceUnit.C urrency, Close[0]) Reference: https://ninjatrader.com/support/help...profitloss.htm

        The strategies RealizedPNL through SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit) Reference: https://ninjatrader.com/support/help...?cumprofit.htm

        The strategies, in general, do not know of other strategies so the above return the values related to that strategy that they are in only.

        You can review the current PNL of all strategies in the Strategies tab of the control center.


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Paul, are you saying that there is no way for one strategy to get the PnL from a different strategy running on the same instrument? Say I have two strategies running on ES. Fred and Ethyl. I want to tell Fred to get the realized PnL from Ethyl. And if the Real PnL from both added together is greater than some amount, close the strategy. You're saying I can't do that? If so, then I won't waste my time trying.... Thanks.

          Comment


            #6
            Hello JoeF1953,

            Thanks for your post.

            It is not possible if you are using the Strategy Builder to pull the values of one strategy to another. (You didn't say but for anyone following)

            It is possible in Ninjascript and somewhat difficult. I do not have an example but you can review the following:
            https://ninjatrader.com/support/help...ount_class.htm as a starting point

            If both strategies are running on the same account please note that they will interfere with each other's account position causing them to be in and out of sync (a long in Ethyl would close a short in Fred and vice-versa but they would maintain their strategy position and continue placing live orders when the profit or targets are hit, so a bit like lucy on the assembly line of chocolates).

            If they are running in separate accounts (recommended practice), then you would need to loop through the accounts and pull the strategy PNL value from each account. Separate Account objects must be added to the strategy, and the strategy would have to loop through acct1.Strategies and acct2.Strategies. You would also want to subscribe to acct1.PositionUpdate and acct2.PositionUpdate and have your code called there. (so when we get an update from acct1, the strategy running on acct2 can see it)
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Thanks Paul. I realize there's no way to do it in Strategy Builder. I have some experience with Script and expected that's the way I would have to do it, if it could be done. I appreciate you pointing out possible conflicts, but with these 2 strategies I've written, its impossible for one to be long and the other to be short at the same time. (One only trades Long and the other only trades Short. Any Long position would have hit Profit Target well before a Short signal would fire, and vice versa.) They both make money, one sometimes much more than the other during the day. So I wanted to add the PnL together and once I hit my daily goal, we're done for the day. I'll check out the link you posted and if I find a way to do what I want, I'll post it for others to use. I sure appreciate you support folks!!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kujista, Today, 05:44 AM
              0 responses
              5 views
              0 likes
              Last Post kujista
              by kujista
               
              Started by ZenCortexCLICK, Today, 04:58 AM
              0 responses
              5 views
              0 likes
              Last Post ZenCortexCLICK  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              172 responses
              2,281 views
              0 likes
              Last Post sidlercom80  
              Started by Irukandji, Yesterday, 02:53 AM
              2 responses
              18 views
              0 likes
              Last Post Irukandji  
              Started by adeelshahzad, Today, 03:54 AM
              0 responses
              8 views
              0 likes
              Last Post adeelshahzad  
              Working...
              X