Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Taking profit at a certain point

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

    Taking profit at a certain point

    I have a strategy that will take profit at a certain point. If I set it to $300 it will take profit at $300.

    However, when I incorporate this into a strategy with a trailing stop loss rather than a static it no longer works.

    What do I need to change so I can apply it to a trailing stop loss strategy?

    #2
    Hello litamm89,

    That would be hard to say what needs to change as we have no information on what you tried. Are you using SetTrailStop or doing something else?

    If you can provide some detail about what code you are trying that would help to direct the question further.

    Comment


      #3
      Hello litamm89,

      I am not certain I understand what the problem is based on the description. Are you saying that your Total PnL exit is being hit rather than your trailing stop? If so you may need to decrease the amount of ticks for the trailing stop so it can fill before your exit happens.

      Comment


        #4
        NinjaTrader_Jesse

        I apologize I didnt see you responded.

        The problem is the Total PnL does not work when a tick trail is introduced.

        What do you mean by decrease the amount of ticks for the trailing stop?

        Comment


          #5
          Hello litamm89,

          I still am not sure I understand what problem you are having, what specifically is not working with the total pnl? Is your condition not working or what part of the code are you saying is not working?

          If you are saying that your condition is not working, this condition:

          Code:
          if ((TotalPNL[0] >= 1000)
          || (TotalPNL[0] <= -1100))​
          You would need to add a Print to see what's happening:

          Code:
          Print(Time[0] + " PnL: " + TotalPNL[0]);
          if ((TotalPNL[0] >= 1000)
          || (TotalPNL[0] <= -1100))

          Comment


            #6
            NinjaTrader_Jesse

            I apologize, I am not the best at explaining things. The condition isnt working. Once the Total PNL from the day hits $1000 it should exit the position.

            The code I have attached above works for a static strategy say exit at $330 when there is a 4.5 point target profit and 3 point stop loss. It will exit and work properly.

            The problem I now have is that if I introduce a tick trail it no longer follows the condition to exit once the Total PNL reaches the goal of $1,000.

            Does that clear things up?

            Comment


              #7
              Hello litamm89,

              Unfortunately that doesnt help to better understand what may be happening. I can only see the small portion of the code you provided so I don't see what could be the problem based on that.

              If the exit stopped working you could use a Print to make sure the condition is becoming true still. You can also use TraceOrders = true to output all order information to make sure nothing is being ignored.

              An exit order will work while you have orders from the Set methods working. The Set methods are based on the entries signal name, when the entry position is closed those targets will be cancelled. Adding a SetTrailStop shouldn't have any effect on the exit working or not.


              Comment


                #8
                NinjaTrader_Jesse

                Ok where in the code would I add that print copy?

                Comment


                  #9
                  Hello litamm89,

                  You could put a print inside the condition to see if its becoming true. You would need to determine where to put prints in your actual script, you would generally place them where they would be relevant to let you know how its code is working .You can find some information about debugging your code here:

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, Today, 05:17 AM
                  0 responses
                  46 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  126 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  66 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  42 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  46 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X