Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

not, not or

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

    not, not or

    Hello,

    I couldn´t find on the support sites how to do for having "not" in the script eg

    if(conditon1
    && condtion2

    && not condition3
    && not (condition4 || condition5)


    Thanks
    Tony
    Last edited by tonynt; 04-07-2012, 05:15 AM. Reason: typing error

    #2
    Originally posted by tonynt View Post
    Hello,

    I couldn´t find on the support sites how to do for having "not" in the script eg

    if(conditon1
    && condtion2

    && not condition3
    && not (condition4 || condition5)


    Thanks
    Tony
    Hi Tony,

    Try something like this.

    if(conditon1&& condtion2 && (!condition3) && (!condition4 || !condition5)

    RJay
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Hello RJay,

      thank you very much for your reply.

      Have a great day!


      Best
      Tony

      Originally posted by rt6176 View Post
      Hi Tony,

      Try something like this.

      if(conditon1&& condtion2 && (!condition3) && (!condition4 || !condition5)

      RJay

      Comment


        #4
        pay attention guys,

        in boolean algebra the condition:

        Code:
        not (condition4 or condition5)
        is different to:

        Code:
        (not condition4 or not condition5)
        the right result is:

        Code:
        (not condition4 AND not condition5)
        c# code is:
        Code:
        (!condition4 && !condition5)





        the simple boolean operations in C# are:

        &&: and
        ||: or
        !: not

        bye everyone!

        wyatt

        Comment


          #5
          Thank you!

          Originally posted by wyatt376 View Post
          pay attention guys,

          in boolean algebra the condition:

          Code:
          not (condition4 or condition5)
          is different to:

          Code:
          (not condition4 or not condition5)
          the right result is:

          Code:
          (not condition4 AND not condition5)
          c# code is:
          Code:
          (!condition4 && !condition5)
          http://en.wikipedia.org/wiki/De_Morgan's_laws



          the simple boolean operations in C# are:

          &&: and
          ||: or
          !: not

          bye everyone!

          wyatt

          Comment


            #6
            Wyatt, thank you!

            Originally posted by wyatt376 View Post
            pay attention guys,

            in boolean algebra the condition:

            Code:
            not (condition4 or condition5)
            is different to:

            Code:
            (not condition4 or not condition5)
            the right result is:

            Code:
            (not condition4 AND not condition5)
            c# code is:
            Code:
            (!condition4 && !condition5)
            http://en.wikipedia.org/wiki/De_Morgan's_laws



            the simple boolean operations in C# are:

            &&: and
            ||: or
            !: not

            bye everyone!

            wyatt

            Comment


              #7
              Some additional related info...

              http://msdn.microsoft.com/en-us/library/6373h346.aspx

              In the following examples, the expression that uses || evaluates only the first operand. The expression that uses | evaluates both operands. In the second example, a run-time exception occurs if both operands are evaluated.

              Code:
              [COLOR=blue]static [COLOR=blue]bool[/COLOR] Divisible([COLOR=blue]int[/COLOR] number, [COLOR=blue]int[/COLOR] divisor)
                  {
                      [COLOR=green]// If the OR expression uses ||, the division is not attempted[/COLOR]
                      [COLOR=green]// when the divisor equals 0.[/COLOR]
                      [COLOR=blue]return[/COLOR] !(divisor == 0 || number % divisor != 0);
              
                      [COLOR=green]// If the OR expression uses |, the division is attempted when[/COLOR]
                      [COLOR=green]// the divisor equals 0, and causes a divide-by-zero exception.[/COLOR]
                      [COLOR=green]// Replace the return statement with the following line to[/COLOR]
                      [COLOR=green]// see the exception.[/COLOR]
                      [COLOR=green]//return !(divisor == 0 | number % divisor != 0);[/COLOR]
                  }
              [/COLOR]

              Comment


                #8
                borland, thank you!
                Originally posted by borland View Post
                Some additional related info...

                http://msdn.microsoft.com/en-us/library/6373h346.aspx

                In the following examples, the expression that uses || evaluates only the first operand. The expression that uses | evaluates both operands. In the second example, a run-time exception occurs if both operands are evaluated.

                Code:
                [COLOR=blue]static [COLOR=blue]bool[/COLOR] Divisible([COLOR=blue]int[/COLOR] number, [COLOR=blue]int[/COLOR] divisor)
                    {
                        [COLOR=green]// If the OR expression uses ||, the division is not attempted[/COLOR]
                        [COLOR=green]// when the divisor equals 0.[/COLOR]
                        [COLOR=blue]return[/COLOR] !(divisor == 0 || number % divisor != 0);
                
                        [COLOR=green]// If the OR expression uses |, the division is attempted when[/COLOR]
                        [COLOR=green]// the divisor equals 0, and causes a divide-by-zero exception.[/COLOR]
                        [COLOR=green]// Replace the return statement with the following line to[/COLOR]
                        [COLOR=green]// see the exception.[/COLOR]
                        [COLOR=green]//return !(divisor == 0 | number % divisor != 0);[/COLOR]
                    }
                [/COLOR]

                Comment


                  #9
                  Does anyone know if NTrader can be connected to my Charles Schwab account? Sorry.... I couldn't figure out where to post this question. Thanks for your help!

                  Comment


                    #10
                    Hello isto313,

                    Unfortunately this is not possible - Charles Schwab is not a supported broker with us. You can find a list of supported broker partners at the link below.
                    JasonNinjaTrader Customer Service

                    Comment


                      #11
                      Clearly:
                      || is an Operator for Bool type operation,
                      but,| is an Operator for Bit wise operation:eg,byte(00010001)|byte(00100010)=byte(00 110011)
                      Yours truly.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by bortz, 11-06-2023, 08:04 AM
                      47 responses
                      1,612 views
                      0 likes
                      Last Post aligator  
                      Started by jaybedreamin, Today, 05:56 PM
                      0 responses
                      9 views
                      0 likes
                      Last Post jaybedreamin  
                      Started by DJ888, 04-16-2024, 06:09 PM
                      6 responses
                      19 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by Jon17, Today, 04:33 PM
                      0 responses
                      6 views
                      0 likes
                      Last Post Jon17
                      by Jon17
                       
                      Started by Javierw.ok, Today, 04:12 PM
                      0 responses
                      22 views
                      0 likes
                      Last Post Javierw.ok  
                      Working...
                      X