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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          160 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          307 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          244 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          348 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          178 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X