Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to use a OR statement in script

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

    How to use a OR statement in script

    Example : close[0] > Open[2] && close[0] >= High[1];

    After or before the " ; " at the end of this statement can I place " OR " and include a different rule/condition

    like this

    close[0] > Open[2] && close[0] >= High[1] OR close[0] > Open[1] && close[0] >= High[1];

    Thanks


    #2
    Originally posted by DTSSTS View Post
    Example : close[0] > Open[2] && close[0] >= High[1];

    After or before the " ; " at the end of this statement can I place " OR " and include a different rule/condition

    like this

    close[0] > Open[2] && close[0] >= High[1] OR close[0] > Open[1] && close[0] >= High[1];

    Thanks
    Not that way. Likely what you are seeking is:
    Code:
    (close[0] > Open[2] && close[0] >= High[1]) || (close[0] > Open[1] && close[0] >= High[1]);
    Pay close attention to your bracketing. It is critical.

    As your AND condition is identical, you can write that more efficiently, to only evaluate the condition if a shorter initial condition fails.
    Code:
    ((close[0] > Open[2]) || (close[0] > Open[1]) && close[0] >= High[1]);
    Or even more concise:
    Code:
    close[0] > Math.Min(Open[2], Open[1]) && close[0] >= High[1];
    Last edited by koganam; 05-05-2019, 05:32 PM.

    Comment


      #3

      (close[0] > Open[2] && close[0] >= High[1]) || (close[0] > Open[1] && close[0] >= High[1]); understand the brackets, like algebra. ^ What key is that above my ^ symbol JUST WANT TO BE SURE IT IS 2 KEY STROKES OF the "SHIFT" OF \ THANKS ALOT

      Comment


        #4
        Originally posted by DTSSTS View Post
        ^ What key is that above my ^ symbol JUST WANT TO BE SURE IT IS 2 KEY STROKES OF the "SHIFT" OF \ THANKS ALOT
        That would depend on what keyboard layout you have. I have function keys above the key "^/6" row, so I am a bit lost on your question. Specifically I have F6 above the ^/6 key.

        Comment


          #5
          THANKS i will test

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          152 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          305 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          244 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          345 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          176 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X