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 algospoke, Yesterday, 06:40 PM
      2 responses
      23 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      21 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X