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

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 zstheorist, Today, 07:52 PM
          0 responses
          2 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          149 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          5 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          5 views
          0 likes
          Last Post tkaboris  
          Working...
          X