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.

    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

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by LawrenHom, Today, 10:45 PM
            0 responses
            3 views
            0 likes
            Last Post LawrenHom  
            Started by love2code2trade, Yesterday, 01:45 PM
            4 responses
            28 views
            0 likes
            Last Post love2code2trade  
            Started by funk10101, Today, 09:43 PM
            0 responses
            7 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            37 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Yesterday, 08:51 AM
            8 responses
            44 views
            0 likes
            Last Post bill2023  
            Working...
            X