Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changin "&" conditions to "or" for multiple comparisons.

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

    Changin "&" conditions to "or" for multiple comparisons.

    Hi Guys,

    I am having trouble finding any reference on this support or the user manual to applying "or" in the strategy wizard or in direct coding. For instance I want to check for multiple types of volume expansion being, for instance I want ANY one of the following to return TRUE for the condition to be met, not ALL of the following;

    if (VOLMA(VOLavPERIOD)[0] > VOLMA(VOLavPERIOD)[VOLavBARS]
    && VOL()[0] > VOL()[1]
    && VOL()[0] > VOL()[2]
    && VOL()[0] > VOL()[3])
    {

    Please let me know.

    #2
    Hello visosounds,

    The operator for OR is ||

    That's (shift + \) x 2

    Additional information on operators in NinjaScript is available here:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Code:
      if ((VOLMA(VOLavPERIOD)[0] > VOLMA(VOLavPERIOD)[VOLavBARS])
      || (VOL()[0] > VOL()[1])
      || (VOL()[0] > VOL()[2])
      || (VOL()[0] > VOL()[3]))
      {

      Comment


        #4
        Be very careful .... if the first condition of the '||' is true, the next condition is not checked !!!

        TJ

        Comment


          #5
          Originally posted by Trader.Jon View Post
          Be very careful .... if the first condition of the '||' is true, the next condition is not checked !!!

          TJ
          THAT is what he requested. I quote from his request: "...for instance I want ANY one of the following to return TRUE..."

          Comment


            #6
            Cheers guys, that helps heaps. Very much appreciated.

            Comment


              #7
              Originally posted by koganam View Post
              THAT is what he requested. I quote from his request: "...for instance I want ANY one of the following to return TRUE..."
              koganam,

              I wasnt referencing your supplied solution: my comment was towards the functionality of how C# processes ' || ' ... no judgement of the code in my bytes.

              Jon

              Comment

              Latest Posts

              Collapse

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