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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      68 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      55 views
      0 likes
      Last Post CarlTrading  
      Working...
      X