Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Stops

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

    Time Stops

    Looking for a clean way to integrate time stops. My strategy currently scales in every bar for 10 consecutive entries. Each one of these entries needs a time stop of maximum 15 bars. I've tried individually naming entry signals and referring to them individually after 15 bars but it is getting messy. Anyone done this already?

    thanks

    #2
    Hello Moneybags,

    Have you tried using BarsSinceEntry() for this? You can optionally include the entry signal name for this method.

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Yes, I have tried that. What i realized at that time was that there was no way around recording and keeping a list of entry signals (I use CurrentBar) and then looping through these signals to compare Bars Since Entry. Since I had to keep a list either way, I decided to use a struct with entrybar signal and exit bar signal (recorded at the time of entry). However, now that I have to keep a list of signals/positions, I also find myself having to sychronize with execution fills to remove items from the list. Order mgmt is getting messy. Ideally, if I could just loop through Positions in NT I wouldn't have to keep a list myself. Or, if I could set a time stop at the time of entry and forget about it, that would be nice.

      thanks

      Comment


        #4
        Hi Moneybags,

        You might consider using BarsSinceEntry without specifying the entry signal.

        This will work if the quantity of your entry orders is the same across all 10 entries.

        Code:
         
        if (BarsSinceEntry() == 15)
        {
        ExitLong(1);
        }
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          That seems to do the trick quite well. Originally when I used that logic, it would exit all entries since BarsSinceEntry was referencing the earliest entry. But fixing the size on exit (instead of referencing the unique position ID), subsequent calls to BarsSinceEntry refer to the next position. This is a good workaround, although if I decided not to exit that specific position at 15 bars and extended it another 15 while the rest remained the same, this would get tricky.
          In any case, thanks for the help, the code is clean and simple, much appreciated.

          Comment


            #6
            Yes, good point. This works well when it's your only exit condition or your other exits fill prior to this.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            647 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            368 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            108 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            571 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            573 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X