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

Reset SetProfitTarget

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

    Reset SetProfitTarget

    According to your documentation of the SetProfitTarget method:
    "you should always reset the target price/offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your profit target order on your next open position".
    How do I reset the target price/offset value?

    Thanks

    #2
    Hello kiss987,

    Thank you for your post.

    You can find an example of this for the SetStopLoss at the following link: http://ninjatrader.com/support/forum...ead.php?t=3222

    Please let me know if you have any questions.

    Comment


      #3
      Thank you for your reply.
      Allow me to clarify my question. Suppose I set a stop loss for my first position. Then, on my second position I don't want stop loss at all. How can I do that?

      Comment


        #4
        Hello kiss987,

        Thanks for your post.

        If you can separate your entries and assign them signal names, you can then assign a SetStoploss to a particular entry and not the other.

        Here is the SetStopLoss link: http://ninjatrader.com/support/helpG...etstoploss.htm You would need to use the method overload that shows signalname
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Suppose I set a stop loss to my position using the SetStopLoss method and after a while (before the position is closed) I want to remove the stop loss. How can I do that?

          Thanks

          Comment


            #6
            Hello kiss987,

            There is no supported method to remove a SetStopLoss, you can however change the value that the SetStopLoss is set at to effectively remove it. If you were to do that, when flat, you would want to reset your SetStopLoss in preparation for your next entry.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hi
              How can I reset my SetStopLoss in preparation for your next entry after my first position is flat?

              Comment


                #8
                Hello kiss987,

                Thanks for you post.

                You reset your SetStopLoss by reverting to the original value used when you first applied the SetStopLoss. For example if you originally used a 20 tick stop loss and then changed it to some other value during the trade, after the trade was over (you are flat), you would use the SetStopLoss statement to again set your stop loss to the initial 20 ticks so that on the entry of the next trade your stop loss value is preset.

                Example code:

                Code:
                if (Position.MarketPosition == MarketPosition.Flat)
                {
                SetStopLoss (CalulationMode.Ticks, 20); // reset to initial value
                }
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hello,

                  I am having the same kind of issue here. After SetProfitTarget() has been reached, the Script will not enter a New Trade until the Position Changes. [See Attached] This is causing Lost Profits. How do I correct this issue?

                  Thank You in advance,
                  MG.Watts
                  Attached Files

                  Comment


                    #10
                    Hello,

                    By putting SetprofitTarget() and SetStopLoss() in the Order Entry Section for OnBarUpdate() I was able to make it work correctly.

                    // Set 4
                    if ((EMA1[0] > EMA1[1])
                    && (EMA2[0] >= EMA2[1])
                    && (AllowTrade == true)
                    && (OpenPosition == false))
                    {
                    OpenPosition = true;
                    EnterLong(Convert.ToInt32(DefaultQuantity), @"Open Long Trade");
                    SetProfitTarget(@"Open Long Trade", CalculationMode.Currency, Profit);
                    SetStopLoss(@"Open Long Trade", CalculationMode.Currency, Loss, false);
                    }

                    Thank You.

                    Comment


                      #11
                      Hello mg.watts,

                      Thanks for your post and welcome to the Ninjatrader forums!

                      I will also respond to your e-mail on this subject.

                      When the set methods are used, as soon as an entry order is filled, these orders are immediately deployed and will use the last value applied to them. The set methods retain the last value.

                      On your solution, I would suggest putting the EnterLong() at the bottom so that your profit and stop will be set before the order is even placed. As you have it now it is not likely to be a problem but it is a good practice to reset the stop/profit prior to placing the entry.

                      Paul H.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by traderqz, Yesterday, 12:06 AM
                      11 responses
                      27 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by PaulMohn, Today, 03:49 AM
                      0 responses
                      7 views
                      0 likes
                      Last Post PaulMohn  
                      Started by inanazsocial, Today, 01:15 AM
                      1 response
                      9 views
                      0 likes
                      Last Post NinjaTrader_Jason  
                      Started by rocketman7, Today, 02:12 AM
                      0 responses
                      10 views
                      0 likes
                      Last Post rocketman7  
                      Started by dustydbayer, Today, 01:59 AM
                      0 responses
                      4 views
                      0 likes
                      Last Post dustydbayer  
                      Working...
                      X