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

Unrealized PnL calculation...

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

    Unrealized PnL calculation...

    I'm attempting to shorten up the unrealized profit calculation script. There will be a lot of indexes but just for example's sake...

    If I am wanting to use...

    for (int i = 0; i < 2; i++)
    {
    unrlzdPnl += Positions[i].GetProfitLoss(Closes[i][0],PerformanceUnit.Points);
    }

    is this equivalent to my old way of..

    unrlzdPnl = ((Positions[0].GetProfitLoss(Closes[0][0],PerformanceUnit.Points)) + (Positions[1].GetProfitLoss(Closes[1][0],PerformanceUnit.Points)));

    It doesn't seem to be from the print statements. Any idea how I can use the first way to replicate the second?
    Last edited by Delta007; 03-12-2014, 09:07 PM.

    #2
    Delta007, for the first you would need to reset the tracker on each bar update for example, otherwise it would just continue to cumulate across all trades seen which is not what you seek...
    BertrandNinjaTrader Customer Service

    Comment


      #3
      How would the tracker be reset, would this be something with BIP or a bool, or simply just putting the statement within the OBU method?

      Comment


        #4
        Would just set it to 0.0 at your OBU update start, so it only builds the sum of the positions across the indices and would not cumulate.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by arvidvanstaey, Today, 02:19 PM
        4 responses
        11 views
        0 likes
        Last Post arvidvanstaey  
        Started by samish18, 04-17-2024, 08:57 AM
        16 responses
        60 views
        0 likes
        Last Post samish18  
        Started by jordanq2, Today, 03:10 PM
        2 responses
        9 views
        0 likes
        Last Post jordanq2  
        Started by traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        47 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X