Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceExit

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

    BarsSinceExit

    I am building my first strategy and I am trying to have the strategy wait one bar until it tries to enter again. I do not want the strategy to enter on the same bar that it has exited from.

    As far as I understand I would use the BarsSinceExit to do this but when I place this into my strategy it makes no trade at all. I suspect that there is a conflict that when the strategy first starts up it obviously has not made any entries and as a result BarsSinceExit will prevent it from every entering a trade. How do I fix this?

    Thanks, Steven

    #2
    BarsSinceExit()

    Steven,

    I am happy to assist you.

    Are you checking for BarsSinceExit() == -1; ?

    From the help guide example : http://www.ninjatrader.com/support/h...ssinceexit.htm

    Here is an example of using BarsSinceExit();

    Code:
     if ((BarsSinceExit() > 10 || BarsSinceExit() == -1) && CrossAbove(SMA(10), SMA(20), 1))
             EnterLong();
    The "||" is an OR symbol.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      I am using BarsSinceExit () > 1.

      If I understand correctly BarsSinceExit() is set to -1 when the strategy first runs and then changes value to '0' when an exit occurs and will then change from 0 to x after the first exit of the strategy. Is this correct?

      If so how do I put in the OR statement you have suggested in the strategy builder. When I open and look at the code it will not let me make any changes. Is there a trick to entering an OR statement.

      Thanks, Steven

      Comment


        #4
        Steven,

        I am happy to assist you.

        Yes, BarsSinceEntry() is initially set to -1. You can either hit the "unlock code" option and input this manually, or you can create a new "Conditions and Actions" set that has the same behavior as the one with "BarsSinceExit()>1", except that it is now "BarsSinceExit()==-1". Note that unlocking the code is irreversible and you will be unable to use the Strategy Wizard with it again.

        Each "Conditions and Actions" set is considered an "or" whereas any conditions put into each individual set is an "and".

        Please let me know if I may assist further.
        Adam P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        61 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        39 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        21 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        23 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        51 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X