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

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.
    JesseNinjaTrader Customer Service

    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.

      JesseNinjaTrader Customer Service

      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))
          JesseNinjaTrader Customer Service

          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.


              JesseNinjaTrader Customer Service

              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:

                  JesseNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by rocketman7, Today, 09:41 AM
                  2 responses
                  5 views
                  0 likes
                  Last Post rocketman7  
                  Started by traderqz, Today, 09:44 AM
                  2 responses
                  4 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by rocketman7, Today, 02:12 AM
                  7 responses
                  31 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by guillembm, Yesterday, 11:25 AM
                  3 responses
                  16 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by junkone, 04-21-2024, 07:17 AM
                  10 responses
                  150 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X