Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Conditional And/Or Ennry

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

    Conditional And/Or Ennry

    hi NT8 support,

    I realize this is an extremely simple syntax question, but how do I bundle If statements together for If and / If Or. Example

    If( Condition 1
    && Condition 2

    ||

    Condition 1
    Condition 3
    )

    Is there a way to bundle them so I only have to write condition 1 once for a (All need this condition), and so I can pare down the number of total OR statements and their lenth for the number of if statements. thank you!

    #2
    Hello Austiner87,
    You can use as below:-
    Code:
    if( (condition1 && condition2) || (condition3 && condition4) )
    //your code
    else
    //your code
    Hope it helps!

    Comment


      #3
      Hello Austiner87,

      Thanks for your post.

      If I understand correctly you are looking to reduce down the code by only using Condition1 once.

      You currently have if(Condition1 && Condition2 || Condition1 && Condition3), true if 1 + 2 or 1 + 3

      You could rewrite as if (Condition1 && (Condition2 || Condition3)) True if 1+ (2 or 3)
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Extremely helpful, thank you

        Comment


          #5
          Hello S.Kinra,
          I didn't know if I should post here or start a new thread. Let me know if I should just start a new thread. Thanks.

          I'm currently trying to do what the person above was asking. See below: (I getting a lot of chart markers printing on random bars). I have the first condition being one or the other and then the rest of the conditions. Am I trying to do this correctly?

          Thanks again for your time.
          Regards
          James

          if (

          (GomOrderFlowProValues1.RatioLow[0] > RS)
          || (GomOrderFlowProValues1.RatioLow[0] < RW)

          && (Close[0] > Open[0])
          && (Enable_RIA == true)
          && (ShowCT_RIA == false)
          // Trend Filter Disabled
          && (TrendFilter == false)

          // Number Buy IMB
          && (GomOrderFlowProValues1.NbBuyImbalances[0] >= NumberIMB)
          // HiWay Long
          && (Close[0] > EMA1[0])
          //Trend Threshold Value
          && (TOTrimi1[0] < TrendHighThreshold)

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ScottWalsh, 04-16-2024, 04:29 PM
          6 responses
          27 views
          0 likes
          Last Post ScottWalsh  
          Started by frankthearm, Today, 09:08 AM
          10 responses
          35 views
          0 likes
          Last Post frankthearm  
          Started by GwFutures1988, Today, 02:48 PM
          0 responses
          2 views
          0 likes
          Last Post GwFutures1988  
          Started by mmenigma, Today, 02:22 PM
          1 response
          3 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by NRITV, Today, 01:15 PM
          2 responses
          9 views
          0 likes
          Last Post NRITV
          by NRITV
           
          Working...
          X