Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Referencing BarsArray

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

    Referencing BarsArray

    I am having trouble calling on a second instrument for entry criteria. I know this is a noob problem, but can somebody help with this formula?

    Code:
    if (CrossAbove(ROC(11), -6, 1)
                    && Close[0] > 10
                    && Close[0] >= SMA(250)[0]
                    && SMA(Volume, 20)[0] >= 200000
                    && StochasticMomentumIndex(4, 4, 3, 1).SMI[0] < -36)
                    && (Closes[1][0] != (LowestBar(Close[1],65))
                    || TRIX(Close, 15, 1)[1][0] == LowestBar(TRIX(15, 1)[1], 65))
                {
                    EnterLong(DefaultQuantity, "Strata#1");
                }
    I.E. for AAPL and ^COMP
    if A,B,C,D are true for AAPL and E is true for ^COMP then enter long.

    I do have Add("^COMP", PeriodType.Day,1); under initialize

    #2
    Hello Wallabee13,

    Thank you for your post.

    I can see from your logic that you are LowestBar() which returns the Index bar value and not the price.
    Is this what you wanted?

    Closes[1][0] != (LowestBar(Close[1],65)

    This is comparing a double value against an int value
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      I'm not quite sure whether you are asking our telling Cal. What I want is "if close now not equal to the lowest value for the last 65 bars."

      Comment


        #4
        Wallabe,

        You are testing a decimal values against a whole number with Close != Lowestbar();
        Typically you would want to test the same value types here. You would want to use MIN() instead as this returns a double value or the price of that bar.
        http://www.ninjatrader.com/support/h...inimum_min.htm

        Additionally, you will want to use Closes[1] for the DataSeries properties as this returns a data series and not a double value that Close[1] does.

        Let me know if I can be of further assistance.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Min issues

          Ok Cal, I do understand the issue btwn lowest bar and min and have changed my coding. From my 1st post, I have been using Closes since the beginning. The issue I am running into now is trying to reference the second instrument. Is there a way to utilize min()[1][0]??

          I have tried the above, min()[1][0] which I understand may not be able to be referenced, and also tried a if (BarsInProgress == 1). As the first post mentions, is there some way I can test "Closes[1][0] != Min(Low,65)[1][0]"?

          I also tried

          if (BarsInProgress == 1) {
          if (Close[0] != Min(Low,65)[0])
          {
          print ("etc.");
          }}

          Simply, neither of those get triggered.

          Comment


            #6
            Hello Wallabee13,

            Closes[1][0] != MIN(Lows[1], 65)[0]
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              Thanks Cal, that helped and with everything else. I have many more issues on the plate for my scripts but I thank you for solving this one.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 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
              572 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