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

Trail Stops

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

    Trail Stops

    I would like to see an enhanced Trail Stop in NT8 as a feature. Like put a Stop at say the Lowest Low of X bars and then begin to trail it by X ticks instead of using ticks or currency at present. Not sure if the ATM can do it either.
    Thank you.

    #2
    Hello Trader17, thanks for your note.

    It is already possible to do this in a custom strategy written in NinjaScript. If you are interested in searching the NinjaTrader Ecosystem for a software consultant please let me know and I can forward your request to our sales team. I will submit a feature request to add this ability through the user interface.

    Kind regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you. Or can you post an example in here? Like a sample code snippet.
      Thank you.

      Comment


        #4
        Hi Trader17, thanks for your reply.

        You can use LowestBar and pass in the Low series to get the price needed for the initial stop.

        e.g.
        var x = LowestBar(Low, 20);
        Print(x + " Close: " + Close[x]);

        SetTrailStop can be called from within OnBarUpdate, so the trailing price can be modified dynamically.



        Kind regards.
        Last edited by NinjaTrader_ChrisL; 07-02-2019, 02:40 PM.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Thank you. The link above you posted comes back as Page not Found. So I set the lowest low of the last X as a var as shown above and pass that into the Trail Stop in place of ticks or am I wrong?
          Thanks.

          Comment


            #6
            Hello Trader17, thanks for your reply.

            I fixed the link above. In this case, you would just use the Currency CalculationMode. Otherwise just make a method that will convert that price difference to ticks. Get the price from the var x and pass in Low[x] that will be the lowest low of y bars where y is the period of LowestBar.

            Best regards.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Thank you. Can something like this be right?

              var x = LowestBar(Low, 20);
              {
              SetTrailStop(CalculationMode.Price,x );
              }

              Thank you.

              Comment


                #8
                Hi Trader17, thanks for your reply.

                Yes, that is the correct syntax, but applying this within your strategy will take testing to ensure it's working the way you need.

                Kind regards.
                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  I will test it out and see if it works. Also can NT trail by X number of ticks instead of each single tick? Like only move the stop when the market moves 5 ticks in your favor at a time.
                  Thanks.

                  Comment


                    #10
                    Looks like it is not being picked up by NT. I do not see the Trail Stop applied on the chart. I did it this way:

                    var x = MIN(Low, 3)[1];

                    {
                    SetTrailStop("LongTrailStop", CalculationMode.Price, x, false);
                    EnterLong(Convert.ToInt32(DefaultQuantity), "");
                    }

                    Thank you.

                    Comment


                      #11
                      Hi Trader17, thanks for your reply.

                      Try printing out the value of x here:
                      var x = MIN(Low, 3)[1];
                      Print(x);

                      That should tell you why you're not seeing a stop being applied. I can take a look at your script if that does not get you in the right direction.

                      Kind regards.
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks. I have a "x" and "y" for longs and shorts and it seems to be printing more than once on a bar different values. And the stop is not triggered either. Basically I want it to start trailing from the highest high or lowest low of the last X bars and to not update that lowest low or highest high value once when in a position, just trail it from original spot.

                        Also can a trail be done in increments of say 5 ticks instead of a tick at a time?

                        Thanks a lot.

                        Comment


                          #13
                          HelloTrader17, thanks for your reply.

                          If you are getting unexpected results with the code, I recommend using the Print statement to print data at run time and see what the actual values of your stop and target are, also turn on Trace Orders and look to the output window when an order should have been submitted but did not. Trace orders will print a message when orders are ignored for whatever reason.

                          If you wanted to control the frequency of the trail stop update, you should just use the regular SetStopLoss, and perform the trailing manually with logic from OnBarUpdate. Something like: if you get a price change, set a boolean flag, then do not update the price again once 5 ticks have passed. Once 5 ticks have passed, reset the flag and the stop can be moved again.

                          Best regards.
                          Chris L.NinjaTrader Customer Service

                          Comment


                            #14
                            Thank you. It is printing the values but the Trail Stop is not setting it using the variable created.

                            Maybe a future feature to have Trail by X pips instead of one tick at a time?

                            Thanks.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by jclose, Today, 09:37 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post jclose
                            by jclose
                             
                            Started by WeyldFalcon, 08-07-2020, 06:13 AM
                            10 responses
                            1,413 views
                            0 likes
                            Last Post Traderontheroad  
                            Started by firefoxforum12, Today, 08:53 PM
                            0 responses
                            11 views
                            0 likes
                            Last Post firefoxforum12  
                            Started by stafe, Today, 08:34 PM
                            0 responses
                            11 views
                            0 likes
                            Last Post stafe
                            by stafe
                             
                            Started by sastrades, 01-31-2024, 10:19 PM
                            11 responses
                            169 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Working...
                            X