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 junkone, Today, 11:37 AM
          0 responses
          2 views
          0 likes
          Last Post junkone
          by junkone
           
          Started by quantismo, 04-17-2024, 05:13 PM
          5 responses
          34 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by proptrade13, Today, 11:06 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by love2code2trade, 04-17-2024, 01:45 PM
          4 responses
          34 views
          0 likes
          Last Post love2code2trade  
          Started by cls71, Today, 04:45 AM
          2 responses
          10 views
          0 likes
          Last Post eDanny
          by eDanny
           
          Working...
          X