Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Translation %

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

    Translation %

    Hello,

    I wand to ask please what this means "in words": if (CurrentBar % 2 == 0)

    When searching for % I dont get a result.

    Thank you!
    Tony

    #2
    Hello tonynt,

    Thanks for your post.

    % is a Modulus operator. It returns the remainder when the first value is integer divided by the second value.

    A publicly available resource that can explain further can be found here - https://stackoverflow.com/questions/...s-divison-work

    Please let us know if we can be of further assistance.

    Comment


      #3
      Hello Jim,

      thank you for your reply. OK, theoretically clear, not difficult if one knows. But what does mean with "if( CurrentBar % 2 ==0)"?

      I cant get the idea of that logic.

      Thank you!
      Tony

      Comment


        #4
        Hello tonynt,

        The condition reads "If the remainder of CurrentBar integer divided by 2 equals 0, do the following."

        Please let us know if you have any questions.

        Comment


          #5
          Determines if bar number is odd or even.
          eDanny
          NinjaTrader Ecosystem Vendor - Integrity Traders

          Comment


            #6
            Hello,

            thank you Jim and eDanny.

            I found now the thread https://ninjatrader.com/support/foru...de-buttons-nt8 and in #6 you replied me with this snippet.

            In the meantime I could work out everything from the sample script and what I need but I still do not understand " if (CurrentBar % 2 == 0)"there.

            Thank you!
            Tony
            Last edited by tonynt; 03-11-2019, 01:52 PM. Reason: translation error

            Comment


              #7
              Hello tonynt,

              I may suggest to add the following print to better observe what the condition is evaluating.

              Print(String.Format("CurrentBar {0} | (CurrentBar % 2) {1}", CurrentBar , (CurrentBar % 2)));

              CurrentBar 245 | (CurrentBar % 2) 1
              CurrentBar 246 | (CurrentBar % 2) 0
              CurrentBar 247 | (CurrentBar % 2) 1
              CurrentBar 248 | (CurrentBar % 2) 0
              CurrentBar 249 | (CurrentBar % 2) 1
              CurrentBar 250 | (CurrentBar % 2) 0
              We look forward to being of further assistance.

              Comment


                #8
                Hello,

                OK, this is clear. And now I understand that you have used this instead of a "normal" condition, that I would have understood when working with NT for years.

                Thank you!
                Tony

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Mindset, 04-21-2026, 06:46 AM
                0 responses
                88 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by M4ndoo, 04-20-2026, 05:21 PM
                0 responses
                134 views
                0 likes
                Last Post M4ndoo
                by M4ndoo
                 
                Started by M4ndoo, 04-19-2026, 05:54 PM
                0 responses
                68 views
                0 likes
                Last Post M4ndoo
                by M4ndoo
                 
                Started by cmoran13, 04-16-2026, 01:02 PM
                0 responses
                118 views
                0 likes
                Last Post cmoran13  
                Started by PaulMohn, 04-10-2026, 11:11 AM
                0 responses
                67 views
                0 likes
                Last Post PaulMohn  
                Working...
                X