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

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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        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.
              JimNinjaTrader Customer Service

              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 CortexZenUSA, Today, 12:53 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Started by usazencortex, Today, 12:43 AM
                0 responses
                5 views
                0 likes
                Last Post usazencortex  
                Started by sidlercom80, 10-28-2023, 08:49 AM
                168 responses
                2,265 views
                0 likes
                Last Post sidlercom80  
                Started by Barry Milan, Yesterday, 10:35 PM
                3 responses
                12 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X