Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsArray Question

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

    BarsArray Question

    Is there a way of using the statement below where I won't get an error message?

    if Falling(SMA(BarsArray[1], 5[0]))

    Do Something

    #2
    Hello edgeliner,
    You have named an indicator as 5. A class cannot be numerical. Please make sure you are using the correct name.

    Code:
    if Falling(SMA(BarsArray[1], [B][COLOR="Red"]5[/COLOR][/B][0]))
    I look forward to assisting you further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      In your "samplemultitimeframe" example, you have used..........

      If (SMA(BarsArray[1], 5[0]) > SMA(BarsArray[1], 50[0])

      How come that works?

      Comment


        #4
        Hello edgeliner,
        The code in the Sample MultiTimeFrame strategy is:
        Code:
        if (SMA(BarsArray[1], 5)[0] > SMA(BarsArray[1], 50)[0] && ...
        and not
        Code:
        If (SMA(BarsArray[1], 5[0]) > SMA(BarsArray[1], 50[0])
        You have placed the ")" later. It needs to be SMA(BarsArray[1], 5)[0]
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Thank you!

          Comment


            #6
            I'm sorry JoyDeep...... but I still don't understand why this doesn't work?

            if Falling(SMA(BarsArray[1], 5[0]))

            Comment


              #7
              Hello edgeliner,
              The correct overload for SMA is IDataSeries and an integer.
              SMA(IDataSeries input, int period)[int barsAgo]


              In your code, BarsArray[1] is the IDataSeries and 5 will be the period value. 5[0] is not an integer and thus the code returns an error.
              JoydeepNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              649 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              370 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              109 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              574 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              576 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X