Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Checking for valid values

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

    Checking for valid values

    Hi,

    I look for any syntax to check if a BarsArray contains valid values x bars ago.
    For dataseries there is dataseries.ContainsValue(BarsAgo) but I didn't find anything similar for Closes[0] and Closes[1].
    Is there a way to do that?

    #2
    Hello Stephan123,

    ContainsValue() is used for plots and DataSeries so you can use it if you adapt your BarsArray into a series. There is not a similar method available for checking contains value for bar objects specifically.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Closes[0] > Closes[1] BarsArray

      Originally posted by Stephan123 View Post
      Hi,

      ContainsValue(BarsAgo) but I didn't find anything similar for Closes[0] and Closes[1].
      Is there a way to do that?


      Not sure if you were able to get to work or if this is what you were looking for, however, I created a simple work around for multiple time frames to use close > close1. Its not perfect but gets you closer to Closes[0] > Closes[1] using BarsArray. The Idea is to use SMA of 1 as your close for the previous bar in your BarArray and use the close of the current bar on your current chart setting.

      Close[0] > SMA(BarsArray[1],1)[0]

      Translated: Current bar on 5 range chart is > SMA of 1 on 60 minute chart.

      Or you could do it like this:

      SMA(BarsArray[1],1)[0] > SMA(BarsArray[1],1)[1]

      This will give you Close[0] > Close[1] in your BarsArray

      **SMA is based on Close so a SMA of 1 will give you the bars close within your barsarray without all the extra coding.

      Note: I used the Multiple Time frame strategy provided with NT as a template.

      SD



      Comment


        #4
        How about just using Closes[int BarArrayIdx].IsValidPlot(int barsAgo); ?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 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