Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Or conditional

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

    Or conditional

    if (CrossAbove|CrossBelow(blahblah))
    {
    do this
    }


    I receive the following error;
    "Operator "|" cannot be aplied to the operands of type 'method group' and 'bool'. CS0019


    Is there any other way to ensure that, when a value crosses a certain point (travelling either up or down), that either way it triggers a condition ?

    #2
    "or" operator in NinjaScript/C# would be '||' and not '|'.

    "and" operator would be "&&".

    Comment


      #3
      Dierk,

      thank you. Sorry for that error-- I was programming late (2:30AM here).


      I tried '||', and still receive the same error.

      I can't really use >= or <= or < or > for this Strategy, since it contains many values which must be kept separate.


      Or, does '==' work if a bar contains that value (if open and close are not exactly equal to that value) ? For example; open is .8112 and close is .8124. Will an "if (value== .8120)" work ?
      Last edited by Faspomy; 10-31-2008, 01:32 AM.

      Comment


        #4
        Faspomy

        the logical or "||" should work for what you're doing. I'm sure after using || rather than | you receive a different error message; what does it say now.

        In addition, "==" will work for the logical comparison you're attempting with value == .8120

        To reiterate logical statements
        x < y means "If X is Less Than Y"
        x <= y means "If X is Less Than or Equal to Y"
        x > y means "If Y is Less Than X"
        x >= y means "If Y is Less Than or Equal to X"
        x == y means "If X is Equal to Y"

        x = y means set X to Y value

        BitWise logical statements
        x | y
        x & y
        Both of these would be used generally for masking or something to that affect. They are usually cryptic, and can be written out with a bit more to make more sense. I don't recommend using them.

        Hope this helps.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          Mr Logik,

          Thank you for the information.

          The error is actually the same using '||' as using '|'. I will try '==' for this strategy.

          Comment


            #6
            if you can please post the line of code which is causing the error.
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Originally posted by Faspomy View Post
              if (CrossAbove|CrossBelow(blahblah))
              Your attempt to call CrossAbove is missing the parenthesis and parameters. You need to call it like using something closer to this, so NT knows what indicators are supposed to be crossing and how far back to look:

              CrossAbove(EMA(ShortPeriod), EMA(LongPeriod), 1)

              Comment


                #8
                just an example;

                PHP Code:
                     if (CrossAbove||CrossBelow(High, Open, 1))
                            {
                                EnterLong(1,"");
                            } 
                
                I receive the same error no matter what I place into the (XX, XX, 1) brackets. '1' signifies the lookback period. Other than that, I receive an error regarding the use of '||' every time.


                EDIT; when I change the code to 'CrossAbove' or 'CrossBelow' (without "||"), the strategy compiles without issue.
                Last edited by Faspomy; 10-31-2008, 01:49 PM.

                Comment


                  #9
                  Faspomy try it like this.
                  Code:
                  if (CrossAbove(High, Open, 1) || CrossBelow(High, Open, 1))
                  {
                       EnterLong(1, "");
                  }
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Perfect Josh !

                    Thank you.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    580 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    335 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    102 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    554 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    552 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X