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 MSerag, 05-06-2024, 11:52 PM
        5 responses
        26 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Aviram Y, Today, 06:03 AM
        0 responses
        1 view
        0 likes
        Last Post Aviram Y  
        Started by Skifree, Yesterday, 11:21 AM
        5 responses
        17 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by hanaewqydow, Today, 06:02 AM
        0 responses
        1 view
        0 likes
        Last Post hanaewqydow  
        Started by tradingnasdaqprueba, Yesterday, 03:42 AM
        10 responses
        37 views
        0 likes
        Last Post tradingnasdaqprueba  
        Working...
        X