Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

indicator of a multiintrument

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

    indicator of a multiintrument

    I am trying to set up a strategy in which one of the checks is to see if the price is greater than to lower Bollinger Band. However when i call on the Bollinger (or just SMA) it is giving me crazy results as it uses the input of all instruments. Can you please advise?
    thx!

    #2
    *this Bollinger check is being done inside another indicator

    Comment


      #3
      Hello nightriderx,

      You can see a sample multi instrument implementation through Tools > Edit NinjaScript > Strategy.

      If you can share the code snippet you're working with, we can take a look and offer input.
      Ryan M.NinjaTrader Customer Service

      Comment


        #4
        ok so for example to get the closing price of the first instrument i would have:

        Closes[0][0]

        ...of the second instrument...

        Closes[1][0]

        How can I see if Closes[1][0] is > than the Lower Bollinger Band of instrument [1]

        Comment


          #5
          You can use BarsArray [ ] in the Bollinger expression.

          if (Closes[1][0] > Bollinger(BarsArray[1], 13, 3).Lower[0])
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            tried it but am now getting:

            Error on calling 'OnBarUpdate' method for indicator '_' on bar 1: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

            using:
            Print ("wma 50-10: "+ WMA(BarsArray[0],50)[10]);

            I know in a strategy I have to increase the look back period, how do I fix this in an indicator, which as I understood should start plotting/returning data once enough bars are gathered?

            thx!

            Comment


              #7
              You need to follow principles here:
              Make sure you have enough bars in the data series you are accessing

              You may need a check similar to

              if (CurrentBar < 10) return;

              If you need this check for another series, it's with CurrentBars [ ] and then an index value indicating the series.
              Ryan M.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by CarlTrading, 03-31-2026, 09:41 PM
              1 response
              64 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by CarlTrading, 04-01-2026, 02:41 AM
              0 responses
              35 views
              0 likes
              Last Post CarlTrading  
              Started by CaptainJack, 03-31-2026, 11:44 PM
              0 responses
              59 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
              51 views
              0 likes
              Last Post CarlTrading  
              Working...
              X