Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compiler errors even with included indicators

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

    Compiler errors even with included indicators

    I have been trying to modify the True Strength Index to include a signal line and histogram like MACD. I cannot get the code to compile because it says I cannot index on a data type double. The relevant code is:

    double TSICalc = fastAbsEma[0] == 0 ? 0 : 100 * fastEma[0] / fastAbsEma[0];
    double SigCalc = TSICalc * (2.0 / (1 + signalLen)) + (1 - (2.0 / (1 + signalLen))) * TSICalc[1];

    TSI.Set(TSICalc);
    Signal.Set(SigCalc);
    Diff.Set(TSICalc - SigCalc);

    This won't compile even though it is almost a mirror of the included MACD code. Just to see, I tried to compile the included (and unedited) MACD code and got the same error. Can anyone see what the problem is?

    #2
    Please post the error, preferably a shot of the editor with the errors.

    Dan
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    Comment


      #3
      Hello ExAmex,

      Thank you for your post.

      When you compile your indicators, it will compile all of the indicators. So if there are programming errors in indicator A, compiling an unmodified indicator B can produce errors from indicator A.

      Unfortunately I cannot trouble shoot the code with the snippet you have provided.

      Is TSICalc initialized as a data series? Or is the double the first instance of this series? You cannot specify an index value from the double itself. You will first need to create a data series to be initialized.

      Please take a look at the MACD indicator and the fastEma variable from the #region Variables and Initialize() method as an example.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Screen shots of errors

        Here are two screenshots. One is the error I get when I compile the included MACD indicator. The other is the error I get when I try to compile my indicator. The MACD indicator does not declare the data series for the variables it specifies as double in the screenshot and the code does not compile though I can use the indicator just fine.
        Attached Files
        Last edited by ExAmex; 06-29-2011, 06:42 PM.

        Comment


          #5
          Originally posted by ExAmex View Post
          I have been trying to modify the True Strength Index to include a signal line and histogram like MACD. I cannot get the code to compile because it says I cannot index on a data type double. The relevant code is:

          double TSICalc = fastAbsEma[0] == 0 ? 0 : 100 * fastEma[0] / fastAbsEma[0];
          double SigCalc = TSICalc * (2.0 / (1 + signalLen)) + (1 - (2.0 / (1 + signalLen))) * TSICalc[1];

          TSI.Set(TSICalc);
          Signal.Set(SigCalc);
          Diff.Set(TSICalc - SigCalc);

          This won't compile even though it is almost a mirror of the included MACD code. Just to see, I tried to compile the included (and unedited) MACD code and got the same error. Can anyone see what the problem is?
          double SigCalc = TSICalc * (2.0 / (1 + signalLen)) + (1 - (2.0 / (1 + signalLen))) * TSICalc[1];

          TSICalc is declared as a double in the preceding line. You cannot index on a double, only on a DataSeries, if the raw values are doubles. (Never mind ArrayList and other arcana). You can either set it as a DataSeries, or else store the value in a different variable at the end of the current run, and access it on the next run through.

          Comment


            #6
            Thanks for the response. I was using one too many steps. I just used TSI and Signal instead of the interim TSICalc and SigCalc and it works. Thanks koganam and all who replied.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            605 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            351 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            561 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X