Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

operator || cannot be applied to operands of type double and double

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

    operator || cannot be applied to operands of type double and double

    Getting this error for the sample below:
    Code:
    			if(this.TBuySignals.GetValueAt(5) || this.TBuySignals.GetValueAt(4) || this.TBuySignals.GetValueAt(3)
    				|| this.TBuySignals.GetValueAt(2) || this.TBuySignals.GetValueAt(1))
    how do i overcome that??

    #2
    Hello outsource,

    Thanks for your post.

    The error message is indicating that, for example, this.TBuySignals.GetValueAt(5) is resolving to a double value instead of a needed true or false condition.

    In an "if" statement you have conditions that must resolve to true or false. If the condition resolves to true then the action(s) below the If statement (usually contained by "{}") are executed. In your example you have several conditions and using the "OR" operator "||" means that if any of the separated conditions are true the action(s) following the if statement would be executed.

    With a double value, you typically would need to do a comparison to create a logical true or false, for example if (this.TBuySignals.GetValueAt(5) > this.TBuySignals.GetValueAt(4)) would resolve to a true or false condition that would be acceptable to the compiler.

    Likely you would need to review with the originator of the code to determine what comparisons are expected to be made for the if statement to work.

    Comment


      #3
      The code snippet
      Code:
      if(this.TBuySignals.GetValueAt(5)
      is simply being seen something as
      Code:
      if(5.25..
      As stated, it needs a comparison to generate a boolean.

      Comment


        #4
        It`s not a comparison.It`s just kind of the age of the value stored back N bars.

        here`s the snippet that works in NT7 quite well

        if(this.TBuySignals.ContainsValue(5) || this.TBuySignals.ContainsValue(4) || this.TBuySignals.ContainsValue(3)
        || this.TBuySignals.ContainsValue(2) || this.TBuySignals.ContainsValue(1))

        So, how do i make it work with NT8??

        Maybe it`s the NT 8 internal issue?

        Comment


          #5
          I am not sure what type this.TBuySignals actually is but ...
          Code:
          if(this.TBuySignals.ContainsValue(5)...
          is basically asking if this.TBuySignals has the value 5, or has a value 5 bars ago.

          The code snippet
          Code:
          if(this.TBuySignals.GetValueAt(5)
          is basically saying... retrieve the value of this.TBuySignals at bar index 5, or 5 bars back (not sure of the nature of your variable) and then if this value is ... the rest is missing and so NT complains.

          Comment


            #6
            Hello outsource,

            Thanks for your reply.

            In NT7 the extension .ContainsValues() is not the same as GetValuesAt() in NT8. In the case of NT7 it returns a logical true or false. As previously advised GetValuesAt() returns a double value.

            For NT8, use .IsValidDataPoint() reference: https://ninjatrader.com/support/help...ddatapoint.htm Please take care to read the helpguide and heed the warning provided.

            For your example then replace this.TBuySignals.ContainsValue(5) with this.TBuySignals.IsValidDataPoint(5), etc, etc.

            Comment


              #7
              A little off-top, but could you guys also please help me with the string converter?

              In NT 8 it doesn`t recognize the Core part of the snippet below:

              string folder = System.IO.Path.Combine(Cbi.Core.InstallDir,"sounds");

              With what do i have to change it?

              Comment


                #8
                hello outsource,

                Thanks for your reply.

                Yes, off topic.

                Answer: replace Cbi.Core.InstallDir with NinjaTrader.Core.Globals.InstallDir

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                625 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                359 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
                562 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                567 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X