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

Equity calculation

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

    Equity calculation

    Hello,
    I'm trying to calculate the running/ongoing equity curve for a strategy. I see a lot of posts asking about this but I see no solution/formula. So below I'm sharing the calculation I've come up with.

    Does this seem correct?

    Equity = (AccountSize + Performance.AllTrades.TradesPerformance.Points.Cum Profit + (Math.Round(Position.GetProfitLoss(Close[0], PerformanceUnit.Points), 4, MidpointRounding.ToEven) * Position.Quantity))

    I'm using this formula within OnBarUpdate to get a continuous equity curve.

    I'm not sure whether to use Points or Currency. For equities are both the same?

    Regards.

    #2
    sajosh,

    Points will be in "ticks" essentially and currency will be in actual currency. You need to be sure you calculation has either all variables in points, or all variables in currency.

    An equity curve is a change in value of an account/portfolio over time minus margin requirements. As such, you could add AccountSize + CumulativeProfit - Margin to get something like what you need. Cumulative profit takes into account losses as well so I am not sure you need the :

    (Math.Round(Position.GetProfitLoss(Close[0], PerformanceUnit.Points), 4,MidpointRounding.ToEven) * Position.Quantity)
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Between a trade entry and exit, the Cumulative Profit stays the same value on each bar update. I'd like to see the value change per bar update. So GetProfitLoss seems to accomplish this. Does that seem right to you?

      Comment


        #4
        Hello,

        Correct, this would get just the current trade PnL however it would update with each new OnBarUpdate().

        Let me know if I can be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GussJ, 03-04-2020, 03:11 PM
        11 responses
        3,228 views
        0 likes
        Last Post xiinteractive  
        Started by andrewtrades, Today, 04:57 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        7 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        440 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        12 views
        0 likes
        Last Post FAQtrader  
        Working...
        X