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 chbruno, Today, 04:10 PM
          0 responses
          3 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          436 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          6 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frslvr, 04-11-2024, 07:26 AM
          9 responses
          127 views
          1 like
          Last Post caryc123  
          Working...
          X