• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to reset SetTrailStop ?

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

    how to reset SetTrailStop ?

    In the documentation it states:

    "Should you call this method to dynamically change the trail stop price in the strategy OnBarUpdate() method, you should always reset the trail stop price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your trail stop order on your next open position"


    I'm using this in both OnBarUpdate as well as OnExecutionUpdate .

    SetTrailStop("MY LONG ALERT",CalculationMode.Ticks, StopLoss, false);


    What is the code to reset the trail stop price??


    The parameter StopLoss is passed in as an input parameter.

    #2
    Hello priceisking,

    If you are using CalculationMode.Ticks and this isn't changing, then you are not calling this method dynamically.

    If the value of StopLoss is changing and you are calling this method multiple times so that you are dynamically changing the number of ticks for the stop loss, that would be dynamically.

    To reset it, you would just set StopLoss back to the original number of ticks and then call the method again.

    Below is a link to an example named ProfitChaseStopTrailSetMethodsExample_NT8 that dynamically changes the price of a stop. It is reset back to the original distance on lines 94 through 103.
    https://ninjatrader.com/support/foru...269#post802269
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea. One quick question. When I place my trailstop, i am unable to get the profit target to get placed. How can i get it to be an OCO. The thing is, I want to be able to move my trailing stop around on the chart. if i use setProfitTarget, the limit order moves back to the previous position when the bar closes.

      if (EnableTrail)
      {
      SetTrailStop("MY L",CalculationMode.Ticks, StopLoss, true);
      targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AverageFillPrice + ProfitTarget * TickSize, "MY L T", "MY L");
      }


      Comment


        #4
        Hello priceisking,

        Thanks for your reply.

        I would expect that the use of ExitLongLimit is being "ignored" based on the internal order handling rules, specifically, "Methods that generate orders to exit a position will be ignored if: A position is open and an order submitted by a set method (SetStopLoss() for example) is active". In this case the set method is the SetTrailStop(), please see, "Internal Order Handling Rules that Reduce Unwanted Positions" on page: https://ninjatrader.com/support/help...d_approach.htm

        In general strategies are not intended for manual interaction and it would be expected that orders would continue to be set back to the place they were upon each update to the strategy's OnBarUpdate() method. You may also create/cause unexpected orders/positions or disable the strategy, depending on the timing of moving the orders and the OnBarUpdate().

        If you wish to be able to move stops/profit targets around then you should look at using the special ATM methods in Ninjascript that allow you to work with a specific ATM template when the strategy has entered a position. The trade then is controlled by the ATM which allows you dynamic adjustments if you wish. Once the trade is closed by the ATM, control returns to the Ninjascript strategy to find and place the next entry. An example of this strategy is in your platform and is called SampleATM strategy. The strategy is a nInjascript strategy and is well commented to help clarify the internal functionality. Here is a link to the specific ATM ninjascript methods you would use: https://ninjatrader.com/support/help...gy_methods.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I'm having a problem with my strategy performing a profit target function in replay. I have a simple crossover strategy using ATR Trailing Stop indicator. I have the profit target set to 7 ticks. On one day (July 11) the strategy worked and took profits every 7 ticks when set to Profit Target Total Position. It did not take profits using Profit Target setting with @long and @short. When I tested the strategy using July 12 replay data, the strategy wouldn't take profits at 7 ticks with either of the settings. I'm using September ES futures contract. Any suggestions as to what is wrong here?

          Comment


            #6
            Hello LTWCI,

            Is this from using SetProfitTarget()?

            Are you getting an ignored message with TraceOrders?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea--yes, used with SetProfitTarget Total Position. How do I see trace orders? I have not used NT in a while. I tested again today and the strategy is working.

              Comment


                #8
                Hello LTWCI,

                Assign TraceOrders = true; in State.Configure.

                Below is a link to the help guide.
                https://ninjatrader.com/support/help...raceorders.htm

                Also, below is a link to a forum post on using prints to understand behavior.
                https://ninjatrader.com/support/foru...121#post791121
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Mykro, Today, 04:58 PM
                0 responses
                2 views
                0 likes
                Last Post Mykro
                by Mykro
                 
                Started by edunwa, Today, 04:11 PM
                0 responses
                6 views
                0 likes
                Last Post edunwa
                by edunwa
                 
                Started by yeshujbp, Today, 02:40 PM
                0 responses
                7 views
                0 likes
                Last Post yeshujbp  
                Started by Venom, Today, 01:05 PM
                0 responses
                10 views
                0 likes
                Last Post Venom
                by Venom
                 
                Started by Dert66, Today, 12:11 PM
                0 responses
                7 views
                0 likes
                Last Post Dert66
                by Dert66
                 
                Working...
                X