Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cannot convert from 'ISeries<double>' to 'float'

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

    cannot convert from 'ISeries<double>' to 'float'

    All of a sudden I am getting this error when I try to compile an indicator that I have been using for months. I changed nothing in the code, and this only started coming up when I made a slight adjustment to another custom indicator I had written.

    The code it seems to be complaining about is:
    Code:
    else if (State == State.DataLoaded)
                {                
                    double myDouble     = 2.5;
                    float myFloat       = (float)myDouble;
                    myIndicator1        = myIndicator(Close, myFloat);
                }​
    myIndicator is the other indicator that I made a slight edit to, but I didn't change much. I just added a separate variable to allow the upper and lower plots of the indicator to be set with different offsets. They're both floats, and I used the same syntax for both.

    Any ideas?

    Thanks in advance!

    #2
    Hello NjTMatthew,

    Thank you for your post.

    What is the full error and the exact line of code referenced in the error? Please post a screenshot along with the line of code the error is referencing.

    Where is myIndicator1 defined?

    Comment


      #3
      Originally posted by NinjaTrader_Gaby View Post
      What is the full error and the exact line of code referenced in the error? Please post a screenshot along with the line of code the error is referencing.

      Where is myIndicator1 defined?
      The specific line the error refers to is the one that calls the other indicator:
      Code:
      myIndicator1     = myIndicator(Close, myFloat);
      The external indicator is prescribed as follows:
      Code:
      public class myNewIndicator : Indicator
      {
           private myIndicator myIndicator1;
      The error says, "Argument 1: cannot convert from 'NinjaTrader.NinjaScript.ISeries<double> To 'float'"

      I'm starting to feel like it does have something to do with the addition of that second variable in the referenced indicator. It's as if I now have to pass it two variables, and I've only re-cast and am passing one.

      Comment


        #4
        Hello NjTMatthew,

        Thank you for your response. The indicator looks defined correctly.

        It may be that you're passing in the wrong parameters to the indicator call (passing in a Series when the indicator is expecting a float).

        To test, if you pass in myFloat for both arguments are you still getting the same error?

        i.e.

        myIndicator1 = myIndicator(myFloat, myFloat);

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X