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 CarlTrading, 03-31-2026, 09:41 PM
              1 response
              67 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              36 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              60 views
              1 like
              Last Post CaptainJack  
              Started by CarlTrading, 03-30-2026, 11:51 AM
              0 responses
              62 views
              0 likes
              Last Post CarlTrading  
              Started by CarlTrading, 03-30-2026, 11:48 AM
              0 responses
              53 views
              0 likes
              Last Post CarlTrading  
              Working...
              X