Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Logical OR

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

    Logical OR

    The Strategy Wizard creates logical AND conditions.

    I want to have a script with a logical OR. And, I don't know how to do it.

    Let me give you my condition from a layman, mathematical prospective. Then, I will paste what the Strategy Wizard created as logical ANDs.

    Layman, mathematical definition:

    If (Fast SMA crosses above Slow SMA) OR
    (Close > Fast SMA AND Close > Slow SMA)
    Enter Long

    This is what the Strategy Wizard created:

    {
    // Condition set 1
    if (CrossAbove(SMA(FastMA), SMA(SlowMA), 1)
    && Close[0] > SMA(FastMA)[0]
    && Close[0] > SMA(SlowMA)[0])
    {
    EnterLong(OrderQty, "");
    }

    // Condition set 2
    if (CrossBelow(SMA(FastMA), SMA(SlowMA), 1))
    {
    ExitLong("", "");
    }
    }


    Thanks

    #2
    StarBright2009,

    Good question!!!

    "OR" in C# is defined by using "pipes" OR = || .

    EX.

    if ((condition10 || condition20) == true)


    You can read up about it here.

    C# logical operators perform logical negation (`!`), conjunction (AND - `&`, `&&`), and inclusive and exclusive disjunction (OR - `|`, `||`, `^`) operations with Boolean operands.


    Hope this helps,

    RJay
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Thank you very much.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      111 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      59 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      38 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      41 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      78 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X