Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

bars in progress

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

    bars in progress

    Hello,

    In the helpguide on ninjatrader.com in the sample ist used else if (BarsInProgress ==1) but in your SampleMultiTimeframe there is not "if/else (BarsInProgress == 1) "

    So, when this is to use please? I can´t understand from your helpguide.

    When I do a strategy eg in 5min timeframe and I have added 2 other timeframes in the strategey eg for stoplosses. Where do I have to code ...(BarsInProgress...)?

    Best
    Tony

    #2
    Hello,

    This is because in the sample is this:

    if (BarsInProgress != 0)
    return;

    This stops all processing on the first series since it returns out of OnBarUpdate() if the BarsInProgress == 0.

    You will always want to use BarsInProgress to choose which time frame you want to calculate on. You want your stops to run on Data from a secondary series be sure to put it in this BarsInProgress.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Brett,

      where do I have to add the (BarsInProgress) for an entry condition:

      if (CrossBelow(Stochastics(BarsArray[3],3, 5, 2).K, Stochastics(BarsArray[3],3, 5, 2).D, 3)

      because when I do
      if (BarsInProgress ==3 && CrossBelow(Stochastics(BarsArray[3],3, 5, 2).K, Stochastics(BarsArray[3],3, 5, 2).D, 3)
      I have no results in backtesting


      and where do I have to add the (BarsInProgress) for stoploss:

      double stop4=HMA(BarsArray[5],89)[0];


      Best
      Tony




      Originally posted by NinjaTrader_Brett View Post
      Hello,

      This is because in the sample is this:

      if (BarsInProgress != 0)
      return;

      This stops all processing on the first series since it returns out of OnBarUpdate() if the BarsInProgress == 0.

      You will always want to use BarsInProgress to choose which time frame you want to calculate on. You want your stops to run on Data from a secondary series be sure to put it in this BarsInProgress.

      Let me know if I can be of further assistance.

      Comment


        #4
        Hello,

        For BarsInProgress == 3 this would mean you want to run on the 4th Bar series.

        Have you added in 4 bar series or only 3?

        If you added in 3 it would be

        BarsInProgress 0
        BarsInProgress 1
        BarsInProgress 2
        BrettNinjaTrader Product Management

        Comment


          #5
          Thank you for your reply.

          I know that
          0 = 1
          1 = 2
          2 = 3
          3 = 4

          The question now finally is WHERE to add this in the coding?

          When I use 4 timeframes, eg 2 for entries and 2 for stoplosses, so with the basic dataseries then there are 5 in total. Where do I have to write (BarsInProgress) so that the entry and the stoploss works correctly?

          Best
          Tony




          Originally posted by NinjaTrader_Brett View Post
          Hello,

          For BarsInProgress == 3 this would mean you want to run on the 4th Bar series.

          Have you added in 4 bar series or only 3?

          If you added in 3 it would be

          BarsInProgress 0
          BarsInProgress 1
          BarsInProgress 2

          Comment


            #6
            Hello,

            You would place it inside of OnBarUpdate and before you take the action you wanted to take in that time frame.

            You have to think of it this way.

            OnBarUpdate() is called for every series. Take this example with a 5 minute series and a 1 minute secondary series.

            OnBarUpdate() - 5 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 5 min


            When you add if (BarsInPorgress == 0) to your code you filter out and do not run on any other BarsInProgress. You would have the following results from any code run with this:

            OnBarUpdate() - 5 min
            OnBarUpdate() - 5 min

            If you use BarsInProgress == 1 you would be running on this series:

            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min

            If you do not specify the BarsInProgress it runs like this:


            OnBarUpdate() - 5 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 1 min
            OnBarUpdate() - 5 min

            Let me know if I can be of further assistance.
            BrettNinjaTrader Product Management

            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
            40 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