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

How to determine daily profit / loss

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

    How to determine daily profit / loss

    Hello,

    I need to find out daily profit / loss of the strategy for risk management purposes, regardless if strategy was restarted.
    However, SystemPerformance seems to start from scratch every time strategy restarts
    I use IncludeTradeHistoryInBacktest = true;

    #2
    Hello michaelsh, thanks for writing in.

    The SystemPerformance class will build up historical trade values as the script runs through the Historical State.

    e.g. These prints will display the number of trades taken by the strategy and the net profit from all the "Virtual" trades taken by the strategy.

    Print("The strategy has taken " + SystemPerformance.AllTrades.Count + " trades.");
    Print("Net profit is: " + SystemPerformance.AllTrades.TradesPerformance.NetP rofit);

    Could you test this on your strategy and let me know if you see any differences?

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,
      Thank you for your answer.
      The SystemPerformance class will build up historical trade values as the script runs through the Historical State
      My strategy is obtaining real time trading signals from external resources, so I can't use historical state.
      My goal is to manage risk by setting maximum daily loss. I can use either Strategy or Account statistics. How would I achieve that?
      Thanks.

      Comment


        #4
        Hello michaelsh, thanks for your reply.

        If the strategy can not get trades from the historical data run you will need to design your own way of getting performance values. Either record the trades and performance metrics to a .txt file or custom database as they happen in real time for future use, or find a way for the external signal generator to work in the historical state. We have an example of reading and writing to a file here:

        https://ninjatrader.com/support/help..._propertie.htm

        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Chris,

          I appreciate your prompt reply.
          Just to confirm: Is there any way I can request list of trades from the Account object?
          Thank you

          Comment


            #6
            Hello michaelsh, thanks for your reply.

            There is not a supported way of getting historical executions from the database. There is an example in NinjaTrader 7 here that reads an SQL database:



            You would need to target the NinjaTrader.sdf in Documents\NinjaTrader 8\db for the execution database. Unfortunately, I have never attempted this so I have no example to give.

            Please let me know if there's anything else I can help with.


            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thank you Chris, this helped

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Aviram Y, Today, 05:29 AM
              0 responses
              2 views
              0 likes
              Last Post Aviram Y  
              Started by quantismo, 04-17-2024, 05:13 PM
              3 responses
              25 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by ScottWalsh, 04-16-2024, 04:29 PM
              7 responses
              34 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by cls71, Today, 04:45 AM
              0 responses
              6 views
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              216 views
              1 like
              Last Post PaulMohn  
              Working...
              X