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

Can I Set a Target and Stop and than Switch to Trailing Stop?

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

    Can I Set a Target and Stop and than Switch to Trailing Stop?

    Can I call the SetProfitTarget(CalculationMode.Ticks, 500) and set my stop to SetStopLoss(CalculationMode.Ticks, 200) and when I hit around let say 300 ticks in the profit area change my stop to SetTrailStop(CalculationMode.Ticks, 100)? Will this work properly managing the orders under the covers?

    #2
    Hello dmisselhorn,

    Yes that will work however you cannot combine SetStopLoss and SetTrailStop. You would need to call SetTrailStop from the beginning if you wanted to use that. If you call the Set methods again while they are already active that will update the existing targets. You would generally use the set methods directly from OnBarUpdate in that use case, for example calling the Set methods before the entry to configure them and then in some other condition that happens later you can call them again.
    Code:
    if(entryCondition)
    {
        SetProfitTarget(CalculationMode.Ticks, 500) ;
        SetTrailStop(CalculationMode.Ticks, 200)
        EnterLong();
    
    }
    
    if(someOtherCondition)
    {
        SetTrailStop(CalculationMode.Ticks, 100)
    }
    JesseNinjaTrader Customer Service

    Comment


      #3
      Are Ninja's trailing stops managed synthetically or do they put actual stop market orders on the market natively as the price moves?

      Comment


        #4
        Hello dmisselhorn,

        Trailing stops are real orders that are sent to the market, the trailing action will happen locally on your machine. When trailing occurs the active order is changed to the new price.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Since that's not exactly the same as I mentioned, if after a bar closes if I reissue a trailing stop, will that push the stop back down to it's original location if it has shifted up?

          Comment


            #6
            Hello dmisselhorn,

            The stop order would be modified to the price supplied or distance from average entry price and would continue trailing from there.

            As far as a stop that becomes a trailing stop later, you could achieve this using exit order methods (instead of set methods) and custom logic.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Could you provide an example, What I really want to do is Trail once I've achieved a portion of the target.

              Comment


                #8
                Hello dmisselhorn,

                The ProfitChaseStopTrailExitOrdersExample linked from post # 6 demonstrates trailing logic.

                On line 235 change this to set the currentSlPrice to the price you want the stop to initially be placed.

                Keep the StopLossDistance at the price at which you want the trailing behavior to begin.

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  SetTrailStop(CalculationMode.Ticks, 100) further into the target run, each time you call it will it update the price with which it's trailing from. Like initially it trails from the position average price, but if you make subsequent calls to it, will it trail at a higher price, thus sliding the trail.

                  Comment


                    #10
                    Hello dmisselhorn,

                    Calling Set methods while the order is working does reset it.

                    If you set the set method before calling the entry and require the position to be flat for a new entry (and not call Set method elsewhere) it would not reset.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      What will it reset to Position.AveragePrice - TrailAmount or when you call it downstream during OnBarUpdate() will it use the current Close[0]-TrailAmount? You didn't really answer my question

                      Comment


                        #12
                        Originally posted by dmisselhorn View Post
                        What will it reset to Position.AveragePrice - TrailAmount or when you call it downstream during OnBarUpdate() will it use the current Close[0]-TrailAmount? You didn't really answer my question
                        Thank you for your patience.

                        That ultimately depends on the CalculationMode being used when you call SetStopLoss() again. For example, if you use CalculationMode.Ticks, with the value set to TrailAmount, then it would be the average entry minus the TrailAmount of ticks. Otherwise, you could use CalculationMode.Price and explicitly set the price to Close[0] - TrailAmount * TIckSize, then it would be set to a price with an offset of TrailAmount from the close price of 0 barsAgo.

                        Please let us know if we may be of further assistance.
                        Emily C.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by AaronKoRn, Today, 09:49 PM
                        0 responses
                        2 views
                        0 likes
                        Last Post AaronKoRn  
                        Started by carnitron, Today, 08:42 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post carnitron  
                        Started by strategist007, Today, 07:51 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post strategist007  
                        Started by StockTrader88, 03-06-2021, 08:58 AM
                        44 responses
                        3,975 views
                        3 likes
                        Last Post jhudas88  
                        Started by rbeckmann05, Today, 06:48 PM
                        0 responses
                        9 views
                        0 likes
                        Last Post rbeckmann05  
                        Working...
                        X