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

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 gentlebenthebear, Today, 01:30 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PhillT, Today, 02:16 PM
            2 responses
            7 views
            0 likes
            Last Post PhillT
            by PhillT
             
            Started by Kaledus, Today, 01:29 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by frankthearm, Yesterday, 09:08 AM
            14 responses
            47 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by PaulMohn, Today, 12:36 PM
            2 responses
            17 views
            0 likes
            Last Post PaulMohn  
            Working...
            X