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?
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DavidHP, Today, 07:56 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by kujista, Today, 06:23 AM
        3 responses
        8 views
        0 likes
        Last Post kujista
        by kujista
         
        Started by Mindset, Yesterday, 02:04 AM
        2 responses
        18 views
        0 likes
        Last Post NinjaTrader_RyanS  
        Started by f.saeidi, Today, 08:03 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by samish18, 04-17-2024, 08:57 AM
        15 responses
        53 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X