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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          51 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          31 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          99 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          177 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          170 views
          0 likes
          Last Post CarlTrading  
          Working...
          X