Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OR || usage

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

    OR || usage

    Hi,

    Trying to use || (OR) like this. Can I (syntax? it errors like this) or do i need separate arguments for each?

    if ((Open[0] || Low[0] || Close[0]) >= MAX(High, 3)[0])

    Cheers

    #2
    Looks ok to me. What's the context and what's the error?

    Comment


      #3
      Strategy\FullBollRSITrail.cs Operator '||' cannot be applied to operands of type 'double' and 'double' CS0019 - click for info 245 12


      Cheers

      Comment


        #4
        on a related part i've got it working as 3 separate conditions, but i've realised on testing the output i need to use barsarray on the highs...but cant get that working.

        If you do have a knack for syntax would probably benefit more from that as not sure of an easy way around. This is under Barsinprogress ==1, and i want the last three highs to be on barsinprogress ==0

        Cheers

        if (Open[0] >= MAX(High, 3)[0]
        || High[
        0] >= MAX(High, 3)[0]
        || Close[
        0] >= MAX(High, 3)[0])

        Comment


          #5
          Tried

          if (Open[0] <= MIN(Lows, 3)[0][0]
          || Low[
          0] <= MIN(Lows, 3)[0][0]
          || Close[
          0] <= MIN(Lows, 3)[0][0]


          actually just got that working...

          if (Open[0] <= MIN(Lows[0], 3)[0]
          || Low[
          0] <= MIN(Lows[0], 3)[0]
          || Close[
          0] <= MIN(Lows[0], 3)[0])

          If you have an answer on the OR question it would be nice to know, although i believe i have my solution.

          Cheers

          Comment


            #6
            Originally posted by Aussiemike View Post
            Tried

            if (Open[0] <= MIN(Lows, 3)[0][0]
            || Low[
            0] <= MIN(Lows, 3)[0][0]
            || Close[
            0] <= MIN(Lows, 3)[0][0]


            actually just got that working...

            if (Open[0] <= MIN(Lows[0], 3)[0]
            || Low[
            0] <= MIN(Lows[0], 3)[0]
            || Close[
            0] <= MIN(Lows[0], 3)[0])

            If you have an answer on the OR question it would be nice to know, although i believe i have my solution.

            Cheers
            Your final solution is correct. Your initial code will not run, as Open[0] et.c., are not logical constructs; they are simply data points.

            Comment


              #7
              If you have an answer on the OR question it would be nice to know, although i believe i have my solution.



              Originally posted by Aussiemike View Post
              Hi,

              Trying to use || (OR) like this. Can I (syntax? it errors like this) or do i need separate arguments for each?

              if ((Open[0] || Low[0] || Close[0]) >= MAX(High, 3)[0])

              Cheers
              the output of each condition separated by the "||" signs should be a boolean, and not a double value like Open[0], Low[0] or Close[0]. So the if statement above should be
              if ( Open[0]>= MAX(High, 3)[0] || Low[0] >= MAX(High, 3)[0] || Close[0] >= MAX(High, 3)[0] )

              Comment


                #8
                If you really want to simplify...

                If ( Math.Min ( Math.Min ( Open[0], Low[0]) , Close[0]) <= MIN(Lows[0], 3)[0])
                {
                MakeMegaBucks2()...
                }

                **please don't throw me under the bus if this doesn't work... I haven't tested any of this... thanks




                Originally posted by Aussiemike View Post
                Tried

                if (Open[0] <= MIN(Lows, 3)[0][0]
                || Low[
                0] <= MIN(Lows, 3)[0][0]
                || Close[
                0] <= MIN(Lows, 3)[0][0]


                actually just got that working...

                if (Open[0] <= MIN(Lows[0], 3)[0]
                || Low[
                0] <= MIN(Lows[0], 3)[0]
                || Close[
                0] <= MIN(Lows[0], 3)[0])

                If you have an answer on the OR question it would be nice to know, although i believe i have my solution.

                Cheers

                Comment


                  #9
                  good idea Sledge to use the Math.Min method

                  Comment


                    #10
                    Originally posted by sledge View Post
                    If you really want to simplify...

                    If ( Math.Min ( Math.Min ( Open[0], Low[0]) , Close[0]) <= MIN(Lows[0], 3)[0])
                    {
                    MakeMegaBucks2()...
                    }

                    **please don't throw me under the bus if this doesn't work... I haven't tested any of this... thanks

                    http://msdn.microsoft.com/en-us/libr...(v=vs.71).aspx
                    Which tells me now that it is all redundant anyway. the Low[0] is ALWAYS the minimum value, so no need to even bother with the other checks if you are checking for the low value against another value.

                    Comment


                      #11
                      ooops,

                      I guess we were focussing to much on the boolean logic in the condition without looking at what's going on. Let's say in our discussion we treated close[0],low[0],open[0] as random variables.

                      Nice call Koganam !

                      Comment


                        #12
                        Cheers...it has made me notice something.

                        The use of the other values Open and Close is simply to ensure i get the first or nearest strike.

                        While the low would indeed meet the criteria the Open might as well, and i'd rather hit that for accuracy (as much as can be without tick data.

                        Close is useless though i believe as this can only hit if the Low does, and after it, so thanks for making me look at this again i'll remove that.

                        I have Open and High for Highs now, and Open and Low for Lows...

                        Cheers

                        Cheers

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        651 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        370 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        109 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        574 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        577 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X