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 TheWhiteDragon, 01-21-2019, 12:44 PM
      4 responses
      541 views
      0 likes
      Last Post PaulMohn  
      Started by GLFX005, Today, 03:23 AM
      0 responses
      2 views
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by XXtrader, Yesterday, 11:30 PM
      2 responses
      11 views
      0 likes
      Last Post XXtrader  
      Started by Waxavi, Today, 02:10 AM
      0 responses
      7 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Started by TradeForge, Today, 02:09 AM
      0 responses
      14 views
      0 likes
      Last Post TradeForge  
      Working...
      X