• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Operator && cannot be applied to operands of type bool and double.

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

    Operator && cannot be applied to operands of type bool and double.

    if (CrossAbove(Aroon(AroonPeriod).Up, Aroon(AroonPeriod).Down, 1)
    && Aroon(AroonPeriod).Up[0] > ARSwitch
    && Variable1 == 2)

    {
    EnterLong(DefaultQuantity, "");
    Variable0 = 0;
    }


    I get the following error:

    Error:
    Operator && cannot be applied to operands of type bool and double.


    Can someone please help? A sample would be very much appreciated, as I am a complte noob to C#

    Thanks.

    #2
    Hi nikolaalx,

    How are these variables declared?

    Specifically is ARSwitch a bool?
    (Aroon(AroonPeriod).Up[0] will return a double)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Not sure if this answers your question:

      private int orderSize = 1000; // Default setting for OrderSize
      private int aroonPeriod = 25; // Default setting for AroonPeriod
      private double profitTaker = 0.020; // Default setting for ProfitTaker
      private double stopLoss = 0.010; // Default setting for StopLoss
      private int exitValue = 1; // Default setting for ExitValue
      private int aRSwitch = 1; // Default setting for ARSwitch
      private int alternateEntryThreshold = 99; // Default setting for AlternateEntryThreshold
      // User defined variables (add any user defined variables below)
      private int lastThreeTrades = 0; // This variable holds our value for how profitable the last three trades were.
      private int priorNumberOfTrades = 0; // This variable holds the number of trades taken. It will be checked every OnBarUpdate() to determine when a trade has closed.
      private int priorSessionTrades = 0; // This varialbe holds the number of trades taken prior to each session break.
      private int lastTrades = 2;
      private int startHours = 16;
      private int startMinutes = 40;
      private int endHours = 22;
      private int endMinutes = 55;

      Comment


        #4
        Here is the full code...might be easier this way.
        Attached Files

        Comment


          #5
          Hello nikolaalx,

          Thank you for attaching your script.

          I have attached screenshots of the errors.

          The first one shows the variables that need to be declared in your script. You have them setup in the properties section but did not declare them.

          The second shows the highlighted ). This is a closing parenthesis to the IF condition and why you are receiving the error message.

          The last one shows another error that I found, which shows that you are trying to assign a value rather than check it. Ensure that you have == in the condition check and not a single =

          Let me know if I can be of further assistance.
          Attached Files
          Cal H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by uiwislth, Yesterday, 11:25 PM
          0 responses
          4 views
          0 likes
          Last Post uiwislth  
          Started by Steve L, Yesterday, 10:04 PM
          0 responses
          3 views
          0 likes
          Last Post Steve L
          by Steve L
           
          Started by marianfed, Yesterday, 09:47 PM
          0 responses
          4 views
          0 likes
          Last Post marianfed  
          Started by hir04068, Yesterday, 09:29 PM
          0 responses
          2 views
          0 likes
          Last Post hir04068  
          Started by iq200, 03-11-2018, 07:49 PM
          24 responses
          1,021 views
          0 likes
          Last Post mrlucky1x  
          Working...
          X