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

test multiple condition

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

    test multiple condition

    If I can test the current bar e the previus I can write:

    if BarColorSeries[0] = Color.Blue && BarColorSeries[1] = Color.Red && BarColorSeries[2] = Color.Yellow;

    Enter Short.....

    It's correct ?

    Tanks

    #2
    Yes, that snippet looks correct to me.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I receive an error compiling CS0019. Why ?

      The sysntax is:


      // Condition set 1

      if (BarColorSeries[0] = Color.Lavender && BarColorSeries[1] = Color.Red)

      {
      EnterLong(DefaultQuantity,
      "");
      }

      // Condition set 2

      if (BarColorSeries[0] = Color.Lavender && BarColorSeries[1] = Color.Green)
      {
      EnterShort(DefaultQuantity,
      "");
      }

      Comment


        #4
        Sorry missed in your previous post that you did not check for equality properly =
        Code:
        if (BarColorSeries[0] == Color.Lavender && BarColorSeries[1] == Color.Red) 
        
        {
        EnterLong(DefaultQuantity, 
        ""); 
        }
        
        // Condition set 2 
        
        if (BarColorSeries[0] == Color.Lavender && BarColorSeries[1] == Color.Green) 
        {
        EnterShort(DefaultQuantity, 
        ""); 
        }
        BertrandNinjaTrader Customer Service

        Comment


          #5
          The same error CS0019

          The code is now

          // Condition set 1

          if (BarColorSeries[0]==Color.Lavender&&BarColorSeries[1]==Color.Red)

          {
          EnterLong(DefaultQuantity,
          "");
          }

          // Condition set 2

          if (BarColorSeries[0]==Color.Lavender&&BarColorSeries[1]==Color.Green)
          {
          EnterShort(DefaultQuantity,
          "");

          Comment


            #6
            I solve the problem....tanks

            Comment


              #7
              Was the code posted that fixed the problem?

              Comment


                #8
                Originally posted by Trader.Jon View Post
                Was the code posted that fixed the problem?
                Not sure TJ what caused it in the end - the snippet I posted works fine here.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,607 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                6 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                15 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X