Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PositionAccount showing 2 values

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

    PositionAccount showing 2 values

    Hi All,
    Im trying to get the unrealized profit from a position with the below code.
    From my understanding in the help guide this should only show the position for the instrument and account the strategy is run on.
    However when running the below i see 2 values, so the end result is its always zero so cant use this, i thought i would only see one value of the current position?
    Where am i going wrong?

    Code:
    unRealizedPnL = PositionAccount.GetUnrealizedProfitLoss(Performanc eUnit.Currency, marketDataUpdate.Last);
    Print("unRealizedPnL: " + unRealizedPnL);
    Thankyou
    Attached Files

    #2
    Hello mr_trade,

    Do you have two instances of the script running? (this would be shown on the Strategies tab of the Control Center)

    Do you have multiple print calls in the script?

    Do you have multiple data series added to the script?

    How do you know there are two values if there is no Time[0] or time included with the print?
    Could this not be the unrealized changing as the price is changing?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thankyou for quick response.
      1. I only have 1 script running in strategies tab.
      2. Multiple prints = no, i have checked and commented out everything so it is only this print now.
      3. I do have multiple data series yes, 1 for tickdata. Is this the problem?
      4. Ive added time for you see new screenshot.
      5. And i have let the trade run a little more so you can see its not fluctuating between profit and zero.
      Thanks again.
      Attached Files

      Comment


        #4
        Hello mr_trade,

        Multiple data series will cause OnBarUpdate() to run for every series added, and Positions will be populated for each series.

        If there are multiple series, there is likely a series using the same instrument as another series, and does not populate with information.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ok thanks. yes so how do i isolate the position to just the primary series where the profit/loss is held for the position?
          Oh wait, you mean just run it on BarsInProgress == 0? Yep that worked lol thankyou!
          Last edited by mr_trade; 04-20-2021, 09:05 AM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by yodaler, Today, 06:12 PM
          0 responses
          5 views
          0 likes
          Last Post yodaler
          by yodaler
           
          Started by op1031, Today, 05:16 PM
          0 responses
          1 view
          0 likes
          Last Post op1031
          by op1031
           
          Started by fscabrera03, Today, 01:18 PM
          1 response
          12 views
          0 likes
          Last Post fscabrera03  
          Started by BottomShark77, Today, 12:20 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by bowling, Today, 06:16 AM
          3 responses
          30 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Working...
          X