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 sjsj2732, Yesterday, 04:31 AM
        0 responses
        33 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        286 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        285 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        133 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        91 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X