Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 cre8able, 02-11-2023, 05:43 PM
      3 responses
      235 views
      0 likes
      Last Post rhubear
      by rhubear
       
      Started by frslvr, 04-11-2024, 07:26 AM
      8 responses
      113 views
      1 like
      Last Post NinjaTrader_BrandonH  
      Started by stafe, 04-15-2024, 08:34 PM
      10 responses
      45 views
      0 likes
      Last Post stafe
      by stafe
       
      Started by rocketman7, Today, 09:41 AM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by traderqz, Today, 09:44 AM
      2 responses
      10 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X