Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,265 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X