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

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.
    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.


                Also, below is a link to a forum post on using prints to understand behavior.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea,

                  This is off topic--will there be a mobile version of Ninja Trader? If there was a mobile version I could enable my strategy before market open and if desired turn the strategy off via mobile app version while at work. Even if the mobile app was bare bones offering only Market Analyzer and Workspace it would suffice. The ability to turn a strategy on or off via mobile would be an advantageous improvement. If the data provider has a mobile app that would work too. Thanks.
                  Last edited by LTWCI; 07-27-2019, 03:42 PM.

                  Comment


                    #10
                    Hello LTWCI,

                    I cannot comment if a mobile version is planned.

                    I will however submit your vote to the feature request for this this.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello LTWCI,

                      I have received tracking ID# SFT-584 for this request for a mobile app.

                      Please note it is up to the NinjaTrader Development to decide if or when a request will be implemented.

                      We appreciate your feedback.
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Chelsea,

                        Great. After taking a few years off to test new strategies, I'm looking to get back to trading with strategies and futures. Does Ninja Trader Brokerage have a mobile app? That would probably solve my need. I've been trading option spreads the past few ears and found the broker's mobile app to be invaluable.

                        Comment


                          #13
                          Hello LTWCI,

                          There may be something from the brokerage side you can use.

                          Please contact brokeragesupport [at] ninjatrader [dot] com for more information.
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Barry Milan, Yesterday, 10:35 PM
                          5 responses
                          16 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by DanielSanMartin, Yesterday, 02:37 PM
                          2 responses
                          13 views
                          0 likes
                          Last Post DanielSanMartin  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          4 responses
                          12 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by terofs, Today, 04:18 PM
                          0 responses
                          11 views
                          0 likes
                          Last Post terofs
                          by terofs
                           
                          Started by nandhumca, Today, 03:41 PM
                          0 responses
                          8 views
                          0 likes
                          Last Post nandhumca  
                          Working...
                          X