Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsSinceExit()==0

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

    BarsSinceExit()==0

    Hallo,

    I have the following condition:

    if (BarsSinceExit()==0 && something else)

    right after the OnBarUpdate.

    It works fine, but if I restart the strategy and there is an open position going on, on the next bar update after restarting, the condition is met.

    It seems that BarsSinceExit() takes the value of zero as soon as there is an open position.

    Is that correct?

    Thanks

    #2
    Hello jriverac,

    When you restart it, it will run the strategy against historical data, but doesn't function any differently. It's not expected to return a value of 0 unless that is the bar that contains an exit.

    I would check log tab of control center for any error messages, and print this value along with the market position to make sure you really are in an open position.

    Print(CurrentBar + " " + BarsSinceExit() + " " + Position.MarketPosition);
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hallo

      There are no error messages. And BarsSinceExit() definitely gets the value of zero when you restart and there is an open position. If there is no open position when restarting, then it works as expected.

      By the way, all this with NT 6.5, WIth NT 7.0 the BarsSinceExit() works as expected. (I know I should upgrade, but meanwhile I would like to get this sorted!!)

      Any help is welcome

      Thanks

      Comment


        #4
        Thanks for the report, and confirming it works as expected with version 7. We suggest using that version or be aware that this is a possible limitation with 6.5.

        Please note that version 6.5 will not receive updates unless there are changes to market data APIs.
        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
        569 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        548 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X