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

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.
        JimNinjaTrader Customer Service

        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.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,607 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          9 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          19 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          6 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          15 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X