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

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.
    Paul H.NinjaTrader Customer Service

    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.
            Paul H.NinjaTrader Customer Service

            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
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by llanqui, Today, 11:10 AM
                0 responses
                4 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by llanqui, Today, 10:29 AM
                0 responses
                5 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by llanqui, Today, 08:32 AM
                1 response
                13 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by lollers, Yesterday, 03:26 AM
                1 response
                53 views
                0 likes
                Last Post lollers
                by lollers
                 
                Started by Salahinho99, 05-05-2024, 04:13 AM
                7 responses
                63 views
                0 likes
                Last Post Salahinho99  
                Working...
                X