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

Problems with Set Profit Target?

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

    Problems with Set Profit Target?

    Hi I have been trying to move my profit targets, but I am experience an interesting phenomena. If I move the profit target, it seems like if I was in a long position, it will exit that position and enter a short position. Would I be better off using an ExitLongLimit instead?

    Thanks

    #2
    - How are you moving it?
    - SetProfitTarget() will not reverse your position so there must be something else triggering a reverse position

    Thanks
    RayNinjaTrader Customer Service

    Comment


      #3
      hmm. I just have SetProfitTarget and SetStopLoss on FirstBarOfTick. I put in debugging statements in the method and it's printing out the stop loss and the profit targets correctly. I am also checking the market position and adjusting the targets accordingly.

      Comment


        #4
        Please take a look at the following reference file for the correct approach to modifying a orders generated by a Set..() method.

        RayNinjaTrader Customer Service

        Comment


          #5
          While it does not explicitly state it, when I submit a new SetProfitTarget does that cancel and replace the old one?

          Comment


            #6
            Not if is at the same price, if its a different price it will change it.
            RayNinjaTrader Customer Service

            Comment


              #7
              Is there a way to "force" a strategy into a position so that I can better debug this?

              Comment


                #8
                Sure, try:

                EnterLong();

                as the first line of your OnBarUpdate() method.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  This is odd. I have EnterLong as the first line of OnBarUpdate and I ran the strategy. I set the session times to 12:00 AM-12:00AM and set the account to Sim101. I have it running on the Simulator feed and nothing clicked in. Are there any other restrictions that are preventing the strategy from entering a trade?

                  Edit: NM, it seems to have clicked in, however the stop and the profit targets are not showing up.
                  Last edited by mazachan; 09-20-2007, 04:35 PM.

                  Comment


                    #10
                    In post #4 there is a link to a reference sample illustrating the correct use of the Set...() methods. A great start would be to take that sample, run that, then make minor modifications so that you become familiar with the operation and expected behaviour.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      Yes, I am currently doing that. However, there does not seem to be any rhyme or reason as to why my code is not working and I am trying to work through that.

                      Thanks for your help Ray.

                      Comment


                        #12
                        Hi Ray, I think I found the issue(s). For some reason if I call SetTrailStop or SetProfitTarget within a helper function in the class, it would not execute an EnterLong order. Once I moved my logic for changing the stops and profit targets to within OnBarUpdate, it seems to have fixed the problem.

                        Comment


                          #13
                          Excellent, thanks for reporting back.
                          RayNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by jclose, Today, 09:37 PM
                          0 responses
                          4 views
                          0 likes
                          Last Post jclose
                          by jclose
                           
                          Started by WeyldFalcon, 08-07-2020, 06:13 AM
                          10 responses
                          1,413 views
                          0 likes
                          Last Post Traderontheroad  
                          Started by firefoxforum12, Today, 08:53 PM
                          0 responses
                          9 views
                          0 likes
                          Last Post firefoxforum12  
                          Started by stafe, Today, 08:34 PM
                          0 responses
                          10 views
                          0 likes
                          Last Post stafe
                          by stafe
                           
                          Started by sastrades, 01-31-2024, 10:19 PM
                          11 responses
                          169 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Working...
                          X