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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        158 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        78 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        125 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        79 views
        0 likes
        Last Post PaulMohn  
        Working...
        X