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 algospoke, Yesterday, 06:40 PM
        2 responses
        22 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        21 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X