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 Guido 01, 07-17-2018, 02:30 AM
              8 responses
              1,265 views
              0 likes
              Last Post pfsmedical  
              Started by cjanau, Today, 11:07 AM
              0 responses
              9 views
              0 likes
              Last Post cjanau
              by cjanau
               
              Started by TrendFollowingCapital, Today, 05:53 AM
              0 responses
              12 views
              0 likes
              Last Post TrendFollowingCapital  
              Started by TrendFollowingCapital, Today, 05:38 AM
              0 responses
              9 views
              0 likes
              Last Post TrendFollowingCapital  
              Started by John Bogui, Today, 03:57 AM
              2 responses
              42 views
              0 likes
              Last Post John Bogui  
              Working...
              X