Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATR based on daily period

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

    ATR based on daily period

    With there being the primary(5min) and the 2 indexes in the script below, in the condition set how do I have the ATR be based on index 1 which would be 14 period based on daily?

    protected override void Initialize()
    {Add(PeriodType.Day, 1);
    Add(PeriodType.Day, 5);
    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if ((Close[0] > Highs[2][0]) && ((Highs[1][0] - Lows[1][0]) > ATR(14)[0] * .75))
    {
    EnterLong(200);
    }
    }

    #2
    Hi zachj, no you would need to base the ATR for example on BarsArray[1] here and then also apply a filter to your condition in OnBarUpdate() to only execute it in a certain BarsInProgress, for example the primary one -



    Comment


      #3
      Is this correct below. The first if statement can use any of the bars in progress(or any of the indexes) and the third if statement will only use index 1?

      protected
      overridevoid OnBarUpdate()
      {

      // Condition set 1
      if (Close[0] > Highs[2][0] && Close[0] < Lows[1][0] * 1.05)

      if (BarsInProgress == 1)

      if (Highs[1][0] - Lows[1][0] > ATR(BarsArray[1], 14)[0]*.75)
      {
      EnterLong(
      200);
      }
      }

      Comment


        #4
        Any statement can use any BarsArray (or Highs, Lows etc for that matter). The difference is then with BarsInProgress when it will be processed, so on which series calling OnBarUpdate - that's the filter here.

        Comment


          #5
          Ok so the process order I have is correct then? The first if statement calls onbarupdate allowing any of the series thru. Then the third if statement calls onbarupdate only allowing the secondary series through due to barsinprogress? Then it will enter long if everything passes.

          Comment


            #6
            You're understanding is correct, I'm not sure though why you would seek to have the first statement not filtered by a BIP.

            Comment


              #7
              How can it be filtered when its using multiple series? The script below is close of primary > High of index 3
              or basically current price on 5min > weekly high

              Close[0] > Highs[2][0]

              Comment


                #8
                The filtering is not for which series you could access in their values and which not - it would be the event on which the code is called an evaluated, meaning the close / update of your primary or added series. You can still access all streams from both series update events.

                Comment


                  #9
                  Im not getting it, isnt it needing to call and evaluate both events in both series? What am I needing to filter.

                  Comment


                    #10
                    Before progressing in that area I would suggest reading through this info and examples here - http://www.ninjatrader.com/support/h...nstruments.htm

                    The data series you've added is accessible from any series, however the filter would decide from which event you're acting on the condition - do you want to check the condition when series 0 updates, or do you want it from series 1?

                    So it's two moving pieces here - the bar update event fired for each series, which is determined by BarsInProgress and the actual reference to the price data array for each series you added.

                    Comment


                      #11
                      Ok so basically I would want it to act on the primary 5min current price data seeing that's what's changing, the highest price in the last week is not changing. So now I have the following correct?...

                      protectedoverridevoid OnBarUpdate()
                      {

                      // Condition set 1
                      if (BarsInProgress == 0)
                      if (Close[0] > Highs[2][0] && Close[0] < Lows[1][0] * 1.05
                      )

                      if (BarsInProgress == 1
                      )
                      if (Highs[1][0] - Lows[1][0] > ATR(BarsArray[1], 14)[0]*.75
                      )
                      {
                      EnterLong(
                      200
                      );
                      }
                      }

                      Comment


                        #12
                        Is the logic below correct?

                        Comment


                          #13
                          zachj, I would work for both conditions and your entry from the primary series so BIP = 0. As you just want to access the higher timeframe info / prices.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          646 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          367 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          108 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          570 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          573 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X