Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

using trailing stops in Strategy builder

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

    using trailing stops in Strategy builder

    Hi

    I have been looking at this excellent video on the strategy builder

    https://www.youtube.com/watch?v=HCyt...We0Nf&index=11

    unfortunately it stops just short of explaining how you would set up a trailing stop.

    I see at the end of the strategy menu there is a setting for trailing stop, but is there a tutorial how to set it up ?

    Many thanks

    #2
    Hello fredfred123,

    Thanks for opening the thread.

    I have created a demonstration video demonstrating how you can set up a Trail Stop and how it works when it is enabled.

    Demo: https://www.screencast.com/t/IXoV3FnFr

    You may wish to further reference the SetTrailStop() method documentation page for a complete understanding of how the method that the Strategy Builder uses works. Additionally, Calculation modes can be referenced in our help guide as well.

    SetTrailStop() - https://ninjatrader.com/support/help...ttrailstop.htm

    Calculation Modes reference - https://ninjatrader.com/support/help...ndTargetValues

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks Jim, that was perfect!

      Comment


        #4
        Would it be possible to demonstrate, using Strategy Builder in NT8, how to create a trailing stop where, for a long trade, price CLOSES below the Keltner midpoint line using a period of 7?

        Thank you.

        Comment


          #5
          Hello Lightheart,

          Welcome to the forums!

          I don't have a demonstration for this specific task, but I may provide some further direction.

          SetTrailStop() can only be placed in the Stops and Targets section of the Strategy Builder and will be triggered after a position is entered. You could create your own trail stop behavior by creating a condition that checks if the Close price is greater/less than your Keltner Channel level and to set a bool to control your stop order.

          When that bool is true, you can submit a stop order to be offset from current Close price. Whenever OnBarUpdate() iterates and the bool is true, the stop will move.

          Keep in mind, using Calculate.OnBarClose will have Close[0] representing the bar that has just closed and Close[1] will represent the previous bar that has closed. Using Calculate.OnEachTick or Calculate.OnPriceChange will change this indexing so Close[0] will be the developing bar/tick, while Close[1] will represent the bar that has just closed.

          I have also attached a picture showing how a condition can be built that checks if Close[0] is greater than a Keltner Channel's midline.

          Please let me know if we can be of further assistance.
          Attached Files
          JimNinjaTrader Customer Service

          Comment


            #6
            Jim (or anyone else),

            I am trying NinjaTrader 8 demo purely for bar by bar trade management.. I currently use ThinkOrSwim and it doesn't have these tools..I have tried creating a Simple strategy and no success yet..

            I enter trades manually and ideally the strategy recognizes a newly opened trade and starts managing the trade 15 minutes later by moving a trail stop 4 ticks above (for shorts) or below (for longs) the prior 15 minute bar... Still reading the manual..!

            Thanks

            Comment


              #7
              Hello Rashid,

              A strategy will only be able to manage positions that are opened by that strategy unless the strategy uses "Adopt Account Position." If using Adopt Account Position, you could enter your position manually and then enable the strategy on that instrument/data series so the strategy begins managing that position.

              If you are using SetProfitTarget/SetStopLoss for the target and stop, these methods may not submit protective orders for an adopted position. I would recommend placing your own logic in Conditions and Actions that submits a profit target and stop loss with the Exit methods under Actions when the strategy position is not flat. I would advise to then have a bool that tells the strategy to submit orders for initial stop loss and when you need to switch to submitting your stop loss to a desired auto trail level.

              AdoptAccountPosition can be set when an unlocked strategy sets IsAdoptAccountPositionAware = true in State.SetDefaults.

              Adopt Account Position and other Start Behaviors can be referenced here - https://ninjatrader.com/support/help...ccountPosition

              IsAdoptAccountPositionAware is documented here - https://ninjatrader.com/support/help...itionaware.htm

              If you do not wish to use AdoptAccountPosition, the strategy will have to open this position using it's own logic and then the strategy will be able to manage those positions.

              Please let us know if we can be of further assistance.
              JimNinjaTrader Customer Service

              Comment


                #8
                Thanks Jim..

                Comment


                  #9
                  Jim,
                  I have decided I want the strategy to handle the entry.. The first step to building this is I want to restrict the price range where the script should run.. I cannot get the script to simply draw lines if price is in a price range.. the sample strategies work fine.. attached are what I have done.. The last is where I input the price range.. Thanks for your help..

                  Attached Files

                  Comment


                    #10
                    Hello Rashid Garuba,

                    Thanks for your question.

                    Your condition written checks if ZoneTop is less-than-or-equal-to the current Close price, AND ZoneBottom is greater-than-or-equal-to the current Close price. Are these values allowing this condition to become true? I have included a demonstration on setting up debugging prints in the Strategy Builder showing how you can monitor your logic as it is executing.

                    Debugging with the Strategy Builder - https://www.screencast.com/t/8uvjfM8h

                    Also to keep in mind when using drawing tools, if you reuse the same Drawing Tool tag, you will update the last Drawing Object that used that tag. To create unique drawing objects, you can add CurrentBar to the tag string.

                    For example:

                    Draw.Dot(this, "tag1"+CurrentBar.ToString(), true, 0, Low[0] - TickSize, Brushes.Red);

                    Let us know if you have any questions on interpreting the debug output.
                    JimNinjaTrader Customer Service

                    Comment


                      #11
                      Hello everyone
                      I am new to this forum. I have a question.
                      this SetTrailStop() is to exit a position. I wonder if there is a SetTrailStop() to enter a position?.
                      Thanks
                      Vinh Phan

                      Comment


                        #12
                        Welcome to the forums VinhPhan!

                        Set methods are used to submit a preconfigured target/stop when an Enter method comes back as filled. They are used to protect your position only and would not be used to enter a position.

                        You could consider the following however:
                        1. In Conditions and Actions, check if the strategy is flat and place your Enter method for a stop or limit order at a price level that is controlled by a variable
                        2. Create another condition in Conditions and Actions that defines when you want to update the entry price for your order. When this condition becomes true, update your variable to the new price level you want it to reside.
                        Variables can be created in the Inputs and Variables page. To update a variable's value in an action block, you can create an action and select Misc > Set MyVariable. A double variable can be created which can hold the decimal values of a price level.

                        If you are new to using the Strategy builder, I suggest referencing our Strategy Builder 301 and Conditions and Actions tips page so you can see how the tool can be used and how various checks, like checking the strategy's position can be made.

                        Strategy Builder 301 (publicly available resource) — https://www.youtube.com/watch?v=_KQF2Sv27oE

                        Conditions examples —https://ninjatrader.com/support/help...on_builder.htm

                        Actions examples — https://ninjatrader.com/support/help...us/actions.htm

                        We look forward to assisting.
                        JimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by hudqwmkohbgp, Today, 10:42 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post hudqwmkohbgp  
                        Started by hudqwmkohbgp, Today, 10:41 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post hudqwmkohbgp  
                        Started by Bidder, Today, 09:16 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post Bidder
                        by Bidder
                         
                        Started by connorgrant5, Today, 07:12 PM
                        0 responses
                        17 views
                        0 likes
                        Last Post connorgrant5  
                        Started by Trader_55, Today, 06:01 PM
                        1 response
                        15 views
                        0 likes
                        Last Post NinjaTrader_EricB  
                        Working...
                        X