Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsArray

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

    BarsArray

    Just a question on how to do barsArray on numeric values. I.e a macd:
    MACD(BarsArray[1], 12, 26, 9)[0] < 0)

    The 0) will be calculated from the current timeframe if I understand this correct. How do I add a different timeframe to a numeric value?

    Regards, Finnbjurvoll

    #2
    Hello Finnbjurvoll,

    Series are added in the Initialize() method. You can see a sample with Tools > Edit NinjaScript > Strategy > SampleMultiTimeFrame.

    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you Ryan, but I'm not sure if you understood my question. Maybe I missunderstand, but you are only adding the period type in the Initialize()? I have no problem adding the period to a indicator, the problem is how to add it to the numeric value? ex:

      protected override void Initialize()
      {
      Add(PeriodType.Minute, 30);
      }

      and the condition:
      if( MACD(BarsArray[1], 12, 26, 9)[0] < 0)
      {
      Do something
      }
      --------
      When I trade a 5 minute chart, the macd calculation will be from the 30 min, right? The problem now is that the zeroline will be calculated from the 5 minute tradingchart. So what I'm saying in the code is when the 30 minute macd is above the 5 min zeroline it will do something. Maybe this is a very dumb question, but I don't understand how to add that 30 minute timeframe to the numeric value.
      Hope I'm not bugging you to much here

      FinnBjurvoll

      Comment


        #4
        BarsArray

        Sorry for the trouble Ryan, my mistake here. Problem solved.
        Have a great weekend.

        FinnBjurvoll

        Comment


          #5
          Thanks for the update, FinnBjurvoll. Glad to hear you were able to resolve. Have a great weekend.
          Ryan M.NinjaTrader Customer Service

          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
          549 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X