Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

daily realized profit and loss

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

    daily realized profit and loss

    I want to get the value of daily realized profit and loss. For example, if the loss hit $2000, then there is no new trade on that day. And this value is reset to be 0 the next day and so on. I noticed there is a function SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit. My question is: Is the begin time of the function the begin time of data series and how to implement the daily updated realized profit and loss in a strategy?

    #2
    Hello Playdc,

    Below is a link to examples of a daily loss limit logic in a strategy.


    The SystemPerformance collection does not reset, and contains all trades made by the strategy instance, including historical and real-time.
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


    The AccountItem.RealizedPnL does reset each day at midnight central time.
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.

    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      Is this the correct syntax if I want to set the daily max loss to be $3000?

      lock (Account.All)
      myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");​

      if (myAccount.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar)<-3000)
      MaxLoss=true;
      else
      MaxLoss=false;​

      Another question is: Is the account in the strategy analysis "Sim101"?

      Comment


        #4
        Hello Playdc,

        The syntax appears correct.

        The backtest account is Backtest and initial values and properties are copied from the Sim101 account, but no orders are placed to the account in a backtest or historical.

        You could choose to get information from the Sim101 account if you would like, but note your strategy backtest will not be affecting any account.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I just tried the codes above and printed the realized gain/loss.

          I got a constant number with all days like
          7/31/2024 6:25:00 AM | Loss: 27.84

          The number is not correct and it does not reset in the middle night.

          Did I do something wrong?

          Comment


            #6
            Hello Playdc,

            The account values would reset at midnight central time zone (the time zone of the NinjaTrader brokerage) if you are connected to a NinjaTrader account. This real-time, current time. Not the time of the bars processing in the strategy.

            This would be the same value showing on the Accounts tab of the Control Center. It would be the same on all days of the strategy as this is not related to the strategy performance or pnl, instead its the current realized pnl value of the account.

            The value you see on the accounts tab of the control center, do you see a position open on the positions tab of the control center, or executions on the executions tab of the control center?

            If you were intending for the realized pnl of the strategy and not the account see the example and information I have provided in post # 2.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Do you mean I could use myAccount.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar) in the real time trading and use the method in post#2 for back testing?

              Comment


                #8
                Hello Playdc,

                The SystemPerformance is the strategy pnl and trades for both historical and real-time.

                The account is the real-time account with its current account values.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                51 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                127 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                69 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                42 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                46 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X