• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to stop strategy trading once daily profit or loss reached

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

    How to stop strategy trading once daily profit or loss reached

    Hello: I would like to know how to program a strategy to stop trading once reached a daily profit or loss using strategy builder. Do I need to know how to code in C## in order to program it ?. Thanks,

    #2
    Hello mtamaku,

    While the Strategy Builder could have a condition for the Realized PnL to be above or below a certain amount, this would not reset on a new trading day. The Realized PnL would continue to be the total PnL through the life of the script.

    Unfortunately, this would mean that the strategy would need to be unlocked and this logic coded by hand.

    The PnL of each trade would need to be tracked, so that this could be reset on each new day.

    Below is a link to an example.
    https://ninjatrader.com/support/foru...ples#post93881
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      hi: Do you have a sample line of code that I can insert in script ? Thanks,

      Comment


        #4
        Hello mtamaku,

        There would not be a single line as this requires logic in multiple methods.

        You can look at the DailyLossLimitExample I provided you a link to and see the code that accomplishes this.

        View lines 53, 54, 57, 63 through 70, and 75 to 80.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Got it. I realized that link was attached. Thanks

          Comment


            #6
            Hello: is it possible to add this option as an NT8 enhancement to reset the daily P&L or Daily Loss limit for each session ? Thanks,

            Comment


              #7
              Hello mtamaku,

              Are you referring to in a strategy or as a general platform feature to have a Daily Loss limit?

              You could inquire with your broker if a daily limit can be added to your account, and strategies would need to have their own logic programmed into them to exit positions and stop trading.

              Do you mean to have a built in strategy property similar to ExitOnSessionClose that would be used for setting a daily limit where you don't have to program the behavior?

              We look forward to hearing back.
              JimNinjaTrader Customer Service

              Comment


                #8
                Hello: I am referring to have this option in strategy builder. I tried that function using the Realized PL compared with a user input variable to a value and it worked only for the first day of strategy starting point and then it stooped as soon as daily profit limit reached since it could not reset the Realized PL to zero for the next day in the range. Or any suggestion on how to reset the daily limit for next day while strategy running.
                Please see the image attached.
                Sorry I do not know how to program in C# so only using Strategy builder. Thanks,
                Attached Files
                Last edited by mtamaku; 07-10-2020, 04:38 PM.

                Comment


                  #9
                  Hello mtamaku,

                  NinjaTrader_PaulH was able to use custom series to allow math with offsets to accomplish this with the Strategy Builder.

                  I've added his example to my post.
                  https://ninjatrader.com/support/foru...ples#post93881
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi
                    I tried this Builder script using MACD condition replacing SMA in the the logic but it keeps trading as per my strategy and does not print anything as per some print command in the strategy.
                    Is this script supposed to check only daily loss and then stop trading if below set value ?
                    I am looking for a script to stop trading as soon it reaches the daily profit limit set by the user input similar to daily loss limit.
                    Thanks,

                    Comment


                      #11
                      Also, I have another script on this daily profit which stops trading after dollar value ($300) other than the set value (500) in the input parameter. Is it possible to send in an email ?
                      Last edited by mtamaku; 07-13-2020, 01:25 PM.

                      Comment


                        #12
                        Hello mtamaku,

                        This is meant to be a learning tool for you to design your own custom logic.

                        Yes, this example demonstrates how to track the daily profit and loss and use this to only place orders if this is greater than a preset loss limit amount.

                        You could create a daily profit limit. You would want to compare the dailypnl to be less than the limit amount instead of greater than the limit amount to place an order.

                        The script demonstrates how to get a dailypnl and use this as you would like.

                        If you would like to email a script to us you can at platformsupport [at] ninjatrader [dot] com.

                        Please note, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. This is so that we can maintain a high level of service for all of our clients as well as our partners.

                        You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.

                        That said, I am happy to answer any questions you may have about NinjaScript if you decide to code this yourself.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by webus, Today, 02:03 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post webus
                        by webus
                         
                        Started by momchi, Yesterday, 07:12 PM
                        1 response
                        14 views
                        0 likes
                        Last Post NinjaTrader_ChrisSch  
                        Started by DieSlower, Yesterday, 11:02 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post DieSlower  
                        Started by gujungg, Yesterday, 10:59 PM
                        0 responses
                        12 views
                        0 likes
                        Last Post gujungg
                        by gujungg
                         
                        Started by DieSlower, Yesterday, 09:46 PM
                        0 responses
                        13 views
                        0 likes
                        Last Post DieSlower  
                        Working...
                        X