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

Cumulative pnl tracking

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

    Cumulative pnl tracking

    I have one strategy that I run several times a day, after every session the strategy disables itself and an auto clicker re-enables it at different trading times throughout the day. My question is: how do I store a cumulative pnl from each session, that is updated after every trade, and is then continually tracked to each instance of the strategy? my goal is to set a cumulative daily loss limit, and if reached within any one of the instances, the auto- enabled instances will not continue trading.

    #2
    Hello ryjoga,

    I would suggest to avoid disabling the strategy if you want to accumulate pnl, each time you disable and re enable the strategy it won't know about the previous runs values, those are all cleared out to start the new instance of the strategy. You can use time conditions to exit or prevent trading instead of actually disabling the strategy.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Well, I have set a profit target limit and when it’s reached, it exits the position and disables the strategy. The reason I have to do that is if I use the close position call from NT it sends a sell/buy order to close, but I’m using Replikanto for follower accounts and that reads the close order call as a new position entry. I don’t want that. So I have to flatten position and exit strategy. I’ve read that I can save a pnl to a file after each instance closes, and then when I re-enable a new instance it will load that file and read the last pnl and add it to new instance. ? How does that work?
      Last edited by ryjoga; 06-17-2024, 12:03 PM.

      Comment


        #4
        Hello ryjoga,

        Regarding saving to file, there is nothing like that built into the platform for strategies. While you can save a value to a text file in C# and read that file at a later time to get the value you saved that won't apply back any values to the strategy its self. That would strictly be for your logic to use but all strategy based properties like its position, PnL, sync with the account, trade/performance information will still be cleared. It would still work like it does now when re enabling to the overall platform. The only way to keep the strategy knowing all of those details would be to keep it enabled. If you are trying to set a profit limit you would generally need to do that in the strategy itself. That is so it can know when to stop trading and submit orders to exit or do whatever it needs to do. From there it could remain enabled and then wait until the next trading session or when you want it to start trading again.

        I wouldn't be able to comment on the third party item and how that works in this situation, you may want to contact the developer of that item to see if they have a specific way they suggest to handle your individual use case while using their product.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Ok, how would I set a profit limit, say $300, during the hours of 2am-3am, once it hits that goal of $300, it stops trading. Still leaving the strategy enabled, have another trading period from 7am-8am, which has a profit limit for that times session of $300 too.. and continue that idea through multiple timed session on one chart/instance. What would be the method to call?

          Comment


            #6
            Hello ryjoga,

            You can see the following links for some examples of that concept. The second link is if you are using the strategy builder. Because the strategy retains data some math is required to find out the current sessions Pnl. Both samples demonstrate a daily loss which can be converted to a daily profit by switching to checking if the value is greater equal to the target amount.


            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by mbafelfel, 05-05-2017, 06:12 AM
            5 responses
            1,367 views
            0 likes
            Last Post Rancher
            by Rancher
             
            Started by Blaze212, 07-07-2024, 08:58 PM
            3 responses
            23 views
            0 likes
            Last Post Blaze212  
            Started by yertle, Today, 12:24 PM
            0 responses
            4 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by reekotubbs, Yesterday, 01:09 PM
            3 responses
            28 views
            0 likes
            Last Post reekotubbs  
            Started by medicmiked, Today, 11:56 AM
            0 responses
            9 views
            0 likes
            Last Post medicmiked  
            Working...
            X