Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Cannot apply indexing with..." error

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

    "Cannot apply indexing with..." error

    Hello,

    I'm developing a simple indicator that uses muti-timeframe data. These lines fail to compile:

    double lo = Lows[1][1];
    double hi = Highs[1][1];
    double op = Opens[1][1];
    double cl = Closes[1][1];

    The two lines with Opens and Closes work, while Highs and Lows don't. Why could this be?

    The error is: " Cannot apply indexing with [] to an expression of type 'double' "

    Thanks
    Ulises
    Last edited by ulisesguerrero; 04-22-2018, 12:35 PM. Reason: New title
    ulisesguerrero
    NinjaTrader Ecosystem Vendor - Thrifty Coders

    #2
    Hello Ulises,

    Welcome to the NinjaTrader forums!

    Are you certain this code is the code causing the error?

    The error indicates that a double (and not a series) has an index applied.

    For example Low (singular) is series of doubles. Lows (plural) is a collection of series.

    Lows[1][1] <- this would not cause an error
    Low[1][1] <- this would cause an indexing order

    if (Lows[1] == 15) <-- this would cause an error that the operator is invalid (because they are not like types)
    if (Low[1] == 15) <- this would not cause an error

    I've copied the exact code you have posted into a script and this is not causing an error on my end.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the welcome. Glad to get a quick reply.

      I did copy the code into a new indicator, and it worked fine. Then I figured that one of the properties created in the wizard was called "Highs" and "Lows" (was hidden with the + icon):

      #region Properties

      [Browsable(false)]
      [XmlIgnore]
      public Series<double> Highs
      {
      get { return Values[0]; }
      }

      [Browsable(false)]
      [XmlIgnore]
      public Series<double> Lows
      {
      get { return Values[1]; }
      }

      [Browsable(false)]
      [XmlIgnore]
      public Series<double> Open
      {
      get { return Values[2]; }
      }

      [Browsable(false)]
      [XmlIgnore]
      public Series<double> Close
      {
      get { return Values[3]; }
      }
      #endregion


      So, I guess it would be good to reject system names/labels when using an indicator or strategy wizard.

      Thanks! Problem solved!
      ulisesguerrero
      NinjaTrader Ecosystem Vendor - Thrifty Coders

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      648 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      369 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      572 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X