Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Make trail stop value update intra bar without indicator update.

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

    Make trail stop value update intra bar without indicator update.

    Can I have my trail stop update on a tick by tick basis without making the indicators change on a tick by tick basis?

    If so what would be the way to effect this with strategy builder or the code?

    Thanks to anyone who can help...

    dendy.

    #2
    Yes you can by running with CalculateOnBarClose = false.

    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray,

      I honestly tried that but I had to shut down the connection and reload the Ninjascripts before it worked.

      Is there any way to allow the trail stop to update intra bar and allow entries to happen only when a bar closes (and conditions are met).

      Thanks again....

      dendy.

      Comment


        #4
        Not exactly what you are looking for, but I add a 15 minute timeframe into my chart that runs on a 1 minute timeframe. The trailing stops adjust every minute but I take all my order entry signals off the 15 minute.

        Comment


          #5
          Woodside,

          If you don't mind me asking, what is the script for doing this. I am testing a 5 min strategy on my IB connection and would like it to update the trailstop every 30 seconds to 1 min if possible. I originally wanted every tick but your solution also sounds very good!

          Thanks for responding...

          dendy.

          Comment


            #6
            Hi dendy,

            The way SetTrailStop() is designed is it will work tick-by-tick and no other way. It does not care what you set CalculateOnBarClose to, it will run tick-by-tick. When you set CalculateOnBarClose to true it means your OnBarUpdate() method will only be executed once at the end of every bar. This means if you have your SetTrailStop() set inside the OnBarUpdate() method then you end up having its value set only when the once per bar at the end. This generally shouldn't be a problem if you call SetTrailStop() immediately after you call EnterLong() or EnterShort(). This caveat also does not mean your Trail Stop order is not working tick-by-tick. Once the order is submitted it will work tick-by-tick until you get stopped out.

            Hope that clarifies your concerns about SetTrailStop().
            For further information please review the documentation here: http://www.ninjatrader-support.com/H...TrailStop.html
            There is also a reference sample that may be of value to you here: http://www.ninjatrader-support.com/v...ead.php?t=3222

            In regards to adding a second time frame to your NinjaScript strategy you can review how to do it here: http://www.ninjatrader-support.com/H...struments.html
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Dendy,

              I use a modified version of the sample multi timeframe strategy. My strategy runs in a 1 minute timeframe, then I add a 15 minute to the strategy, the use BarsArray[1] in all my indicators to determine entrys.

              I found that when backtesting, the results are much more accurate with the trailing stops as the get updated every minute.


              Josh, In my experience the trailing stops only get updated when the bar closes. Is this just because I'm running in simulation? When I run my strategy live with my broker account will it send an actual "trail stop" order to my broker which will then update it tick by tick? Broker is MB Trading which does support trailing stops natively.

              Comment


                #8
                Thanks Woodside and Josh,

                I've been investigating the multi-time frame strategy and this is great stuff. I know it's old news to you. But I'll be trying to use this for the first time.

                As you mentioned Josh, the trail stop is checked on a tick by tick but the value is not updated until the bar closes.

                I will work on this.

                Thanks to all.

                dendy.

                Comment


                  #9
                  I'm still new at this also but I have a fair amount of programming experience.

                  I could never figure out why I couldn't get better performance using trailing stops then just fixed stops. When looking at past bars, ninja has no idea if a high came before or after a low so trailing stops never get updated on the same bar, and your target and/or your stop could get hit on the same bar. Using 1 minute bars seems to help as at least the stop gets updated once every minute.

                  If as Josh says they will get updated tick by tick when trading for real that this isn't an issue, but it sure helps when backtesting. My experience with trailing stops is they update at the close of a bar, and they are adjusted based on the high/low of the previous bar depending on if you are long/short.


                  -Erik

                  Comment


                    #10
                    For clarification.

                    SetTrailStop() will submit a stop loss order immediately on the opening of a position based on internal incoming fill events on an order. The adjustment of the stop loss price (the trailing stop) is adjusted on OnBarUpdate() events which either trigger on the close of a bar or on each tick depending on what your CalculateOnBarClose property is set to.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      I have an issue with trying to use a multi-time strategy to update my trail stop more often than my entry order.

                      I have a multi time frame and not a multi instrument strategy. According to the help file and confirmed by errors, you may only execute orders against the primary time frame. I cannot make the primary time frame 1 minute because I don't want to execute that many entries. Let's say I make the primary time frame 5 minutes, then my entries will run only on 5 min intervals (good). But the trail stop will also update only every 5 minutes unless I find a workable way to command the trail stop to update based on the bars that I add with the Add command. (As woodside said earlier, 1 min bars or so.)

                      Can anyone help with this?

                      Thanks again...

                      Comment


                        #12
                        NT 6.5 will allow you to place orders against all time frames which will solve your road block. We are within weeks of releasing public beta of this.
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          NT 6.5 sounds like it's going to be a huge update...

                          Can't wait to see it.

                          Thanks for clearing that up for us,

                          dendy.

                          Comment


                            #14
                            You could use a counter to do this I think. Load your script on a 1 minute bar, add a 15 minute bar, initialize a counter at 0, then every bar increment it by one, when it hits 15 run your order entry conditions and reset the counter to 0. That way your stops would run every bar but the orders would only trigger every 15th bar.

                            -Erik

                            Comment


                              #15
                              Woodside,

                              I'm trying to use the count command but all the help guide has to say about it is below. The Countif does not work on multi time frame strategies. I'm still trying to make the Count work. I'm slow because I don't know anything about programming.

                              Thanks...

                              Definition
                              The total number of bars or data points.


                              Property Value
                              An integer value representing the the total number of bars.


                              Syntax
                              Count


                              Property Of
                              Custom Indicator, Custom Strategy

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              598 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              343 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              557 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              555 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X