Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

pause or timeout after a trade

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

    pause or timeout after a trade

    Does anyone know of a way to keep an automated strategy from executing a trade for a specified amount time after closing a trade?
    The problem I have is that after a trade closes through a stop or profit target, the conditions that may have initiated the buy/short still exist so that after the trade closes, the strategy enters a buy/short immediately - usually that trade closes out on a stop I just need the strategy to not trade for the next 10 - 30 minutes.
    Thanks

    #2
    Hi flurbo,

    Please try adding to your entry condition BarsSinceEntry().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Danke! Your quick reply is much appreciated. That is an easy thing to implement.

      Comment


        #4
        Hello gplatis,

        Thanks for writing in.

        In the future please refrain from bumping old threads. You may feel free to link to an old thread if you have similar questions, but we try not to pull up older and less relevant threads.

        To respond to your inquiry:

        You can find examples for using BarsSinceEntry() and other aspects of NinjaTrader in the help guide. Here is the example listed:

        Code:
        protected override void OnBarUpdate()
        { 
            if (CurrentBar < 20) 
                return; 
         
            // Only enter if at least 10 bars has passed since our last entry
            if (BarsSinceEntry() > 10 && CrossAbove(SMA(10), SMA(20), 1))
                 EnterLong();
        }
        BarsSinceEntry() Documentation - https://ninjatrader.com/support/help...sinceentry.htm

        To answer your second question, you can place orders at the close of a bar using OnBarUpdate() and CalculateOnBarClose = true. Please look into the documentation on how OnBarUpdate() and CalculateOnBarClose work for complete usage and understanding. Strategies will call OnBarUpdate() on the close of each bar unless CalculateOnBarClose is set to false.

        When using CalculateOnBarClose = false, OnBarUpdate() will be called on each tick, and you can use FirstTickOfBar to identify when OnBarUpdate() is called for the first tick of a new bar.

        Please refer to the documentation below to reference these components.

        OnBarUpdate() - https://ninjatrader.com/support/help...nbarupdate.htm

        CalculateOnBarClose - https://ninjatrader.com/support/help...onbarclose.htm

        FirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

        Please let me know if you have any questions on the material.
        Last edited by NinjaTrader_Jim; 05-01-2017, 08:10 AM.

        Comment


          #5
          Hello gplatis,

          Thanks for sharing your experience and solution on the forums.

          There may have been some confusion while answering your second question, but it sounds like you have found a solution by using BarsSinceExit().

          If there is anything that you would like me to clarify on, please let me know.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          649 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
          576 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X