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

bool arithmetic fundamental

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

    bool arithmetic fundamental

    Hi
    Sorry, I have two very simple questions:
    - In the case of a boolean object can I write 0, and 1 or only true and false
    - I have a boolean vector, named vector. I would like to invert it. (All of parts of them) I tried "!vector" but it was not good. What is the right one?

    Lot of thanks

    Akos

    #2
    Hello,

    In C#, booleans are always true or false, not 1 or 0. Can you please clarify what you mean by a boolean vector? Do you mean a boolean variable? If so, you can swap the boolean to its opposite state via "vector = !vector."

    Please let me know if I can assist further.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Hello Dave


      I have defined an array with three elements :

      bool[] vector = new bool[]{true,true,true}

      now I want to convert all of the elements to false, so I want to invert the array

      Thank you

      Akos

      Comment


        #4
        I believe a for loop would do the job here. Something like:

        Code:
        for (int i = 0; i < vector.length - 1; i++)
        {
              vector[i] = !vector[i]
        }
        Please let me know if I can assist further.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          Hi Dave,
          Thank you for your ansver. I hope that we can make aritmetic with array directly, but it seems not...
          Have a nice day
          Akos

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mgco4you, Today, 09:46 PM
          0 responses
          1 view
          0 likes
          Last Post mgco4you  
          Started by Rapine Heihei, Today, 08:19 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 08:25 PM
          0 responses
          6 views
          0 likes
          Last Post Rapine Heihei  
          Started by f.saeidi, Today, 08:01 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by Rapine Heihei, Today, 07:51 PM
          0 responses
          8 views
          0 likes
          Last Post Rapine Heihei  
          Working...
          X