Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unrealized + realized profits?

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

    Unrealized + realized profits?

    I'm trying to add the prior trades results with the unrealized profit of an open position.

    priorTradesCumProfit = Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit;

    if (Performance.RealtimeTrades.TradesPerformance.Curr ency.CumProfit - priorTradesCumProfit >= 1000.

    ^^ I got this from Josh's sample code.

    I searched and found GetProfitLoss.


    So then I would have

    if (Performance.RealtimeTrades.TradesPerformance.Curr ency.CumProfit - priorTradesCumProfit + Position.GetProfitLoss (Close[0], PerformanceUnit.Points >= 1000.

    Something like that I think? Am I on the right track?

    #2
    Hello,

    To add Realized and Unrealized do something like this:


    Performance.RealtimeTrades.TradesPerformance.Curre ncy.CumProfit + Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)

    These links will help:




    Notice that you must add currency values to currency values, not point values to currency, etc. Also, this will included all Cum. profit not just the days P and L. To take out the prior trade Cum. profit you will need to treat priorTradesCumProfit in the manner it was treated in the sample: inside the if(Bars.FirstBarOfSession) block.
    DenNinjaTrader Customer Service

    Comment


      #3
      ^^^ Thanks. Got it working exactly how I wanted/

      Comment


        #4
        Hello gplatis,

        Thanks for your post.

        The links in the thread are out of date.

        Here are the current NT7 helpguide links to the subjects of CumProfit and GetProfitLoss (unrealized PNL). Each of these links provides a specific example of utilization.

        http://ninjatrader.com/support/helpG...?cumprofit.htm

        http://ninjatrader.com/support/helpG...profitloss.htm

        Can you clarify what you are asking for, "...how do you take out the priorTradesCumProfit ??" I'm not entirely sure what you mean. Do you mean to obtain the last trades PNL or the current PNL of the strategy?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        65 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        41 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        23 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        26 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        52 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X