Announcement

Collapse
No announcement yet.

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:

            https://ninjatrader.com/support/foru...sample?t=10296

            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 thebionukerlife, Yesterday, 11:41 PM
              0 responses
              1 view
              0 likes
              Last Post thebionukerlife  
              Started by thebionukerlife, Yesterday, 11:40 PM
              0 responses
              1 view
              0 likes
              Last Post thebionukerlife  
              Started by KirkHammett, Yesterday, 11:15 PM
              0 responses
              3 views
              0 likes
              Last Post KirkHammett  
              Started by soon123, Yesterday, 11:12 PM
              0 responses
              2 views
              0 likes
              Last Post soon123
              by soon123
               
              Started by JustinCross, Yesterday, 09:48 PM
              0 responses
              10 views
              0 likes
              Last Post JustinCross  
              Working...
              X