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 CarlTrading, 03-31-2026, 09:41 PM
          1 response
          128 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          73 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          116 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          109 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          88 views
          0 likes
          Last Post CarlTrading  
          Working...
          X