Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trailing stop

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

    Trailing stop

    I would like to create a trailing stop that only triggers at the close of bar and not tick-by-tick. I assume it is not as simple as setting CalculateOnBarClose=True?

    #2
    Hello billr,

    Yes, you should be able to use SetTrailStop() with CalculateOnBarClose = true to achieve this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Just to clarify, would this work in live trading but in backtesting the Trailing stop would update tick-by-tick?

      Comment


        #4
        Backtesting will always use CalculateOnBarClose = true.

        Real-time can vary depending on the setting used.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          I thought that the Trailing Stop, Stop Loss and Profit Target remained tick-by-tick even if COBC=true. Not true?

          To be more specific, this inquiry is for application to renko chart. I am aware of the numerous short comings of renko, but I am trying to force the trailing stop to recognize end of bar only.

          On a related note, since the Open of a renko is not defined until it closes, is there a delay in the availability of the Close[0] value until the following bar is completed (renko)? I am not clear on the distinction between "Bar Close" and Close[0] as far as the NT logic when running strategies is concerned.

          Thanks.

          Comment


            #6
            These methods will still use COBC settings. When set to true they are updated at bar close, not tick by tick. Let us know if you're seeing something different.

            Right, the bar is not closed until the next one begins. It will work this way for all chart styles, not just renko. The next bar opening event and the prior bar closing are the same.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ryan,
              Your answer confused me a bit. I realize that that generally speaking, Close[1] corresponds to Open[0]. However with renko, where is Open[0] in the context of your answer? Is it the next tick after Close[1]? Or is it delayed indefinitely until the next renko bar is formed? In backtesting it is the latter which renders backtesting invalid without corrective measures.

              This begs my other question: In Renko, if the price at the close of the bar is 10.00, the next tick is 10.01, but the open of the next bar is at 9.00 (reversal), Does Close[1]=10.00 or 9.00? OR, does Close[1]=10.00 but that data delayed until the next bar is complete?

              Regarding the COBC applying to stoploss and profit targets etc. I really must have my brain checked. I would have sworn that these functions can trigger intra-bar regardless of the COBC setting. Just to be sure, are we talking about the same COBC setting in the Strategy edit/settings window?

              Comment


                #8
                I think I am getting a little off track in this discussion. To recap, I want to set a trailing stop that would trigger ONLY at close of bar if the threshold has been met. I think the earlier response from Ryan's answer confused me because I was focused on the exit, not the entry or placement of the trailing stop itself. From all I have read, the placement or setting of the trailing stop in COBC=true does only happen at bar close. It is the actual trigger point that I am trying to restrict. e.g. If my trail stop is set at 30 ticks and the position is off 30 ticks intrabar nothing happens at that point, but if the bar closes where position is off 38 ticks, then the stop triggers. If that same bar ends up closing higher and the position is off less than 30 ticks, no stop is triggered. This is what I am trying to set up. Thanks for your patience.

                Comment


                  #9
                  Hi Bill,

                  You're right -- most of the time Close[1] is the same value as Open[0]. However, my earlier discussion related to the bar closing event, which is what I thought you were after. A bar isn't closed until the next one begins.

                  You can use your data window on a chart to see OHLC values for a given renko bar. I don't believe they offer any particularities compared to other bar objects. Let us know if you're seeing something different.

                  If you're using Set statements, then it uses the last value it's set to. A stop loss is still there - there's really no way to reset a set statement. If you're using COBC = true, then any adjustments to the stop loss value happen at bar close, not tick by tick.

                  Please test some of these concepts and let us know if you'd like additional clarification.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks Ryan. I do understand what you are saying. The peculiar feature of the renko of course, is the fact that it's Open and Close are really determined in the same event. And therefore, the Open of [0] may occur a full bar distance from Close[1] in price not to mention the time lag.

                    Maybe this will help clarify my question. I am looking for a way to accomplish the following logic:
                    1. Set trailing stop type rule for a threshold to certain number of ticks or percentage;
                    2. If Close[0] meets or exceeds threshold, then do something.
                    3. Else, no action, wait for next bar Close, reset and test again.
                    *In this scenario, the threshold may be met on tick-by-tick basis BUT threshold must be met or exceeded at Close[0]. Otherwise, no action and trailing stop updates and recalculates at next Close. This forces a reversal bar(s) to be formed before any action is triggered.
                    Hope this helps.
                    Thanks.
                    Last edited by billr; 08-05-2010, 11:32 AM.

                    Comment


                      #11
                      Hi bill,

                      Adjustments are made to the trailstop price at bar close when using CalculateOnBarClose = true. You can use CalculationMode.Percent for these orders. It trails the current traded price by the specified percentage.

                      You're going to need to play with it and compare your expecations to how you see it working. If they aren't in line, share the code you're using and your expectations.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Ryan,
                        At the risk of over-explaining, your comment about setting the stop also helps insofar as I don't want to set a stop at the threshold point. I want to trigger an Exit Position if said threshold is met at Close[0].

                        Comment


                          #13
                          Ryan, you are very patient and I appreciate that.
                          Maybe this will help describe what I want to do: I want to use a renko chart and only allow trade actions of any type to be triggered at Close of Bar. The StopLoss within the standard Trailing Stop is set COBC but the setting and trade trigger is independent of bar close levels at that point. It can occur intrabar. I want to construct a trailing stop that will calculate the Close[0] against the highest profit (or highest Close[0] ) of current position. Then either Exit or not based upon the tick/price/percent setting.

                          So going back to my original post, I made a mistake by not clarifying that by "trigger" I meant Exit trade, not Set StopLoss.
                          Thanks again.
                          (This discussion is giving me an appetite for Bros. BBQ on 6th. if they are still there)

                          Comment


                            #14
                            Sorry, I don't follow your last two posts.

                            Share the code that you have attempted to write so far and let us know what you expect it to do. If you're looking for help expressing something in NinjaScript, break it down to the simplest idea and then we can start adding complexity.
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              Hi Ryan,
                              I will be happy to attempt some NS code. I haven't tried yet, and its about time. Could you tell me how to post the code in the "Code:" box? I understand you prefer that over simple typing.
                              Thanks.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              650 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              577 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X