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 BartMan, Today, 07:53 PM
                0 responses
                1 view
                0 likes
                Last Post BartMan
                by BartMan
                 
                Started by Jazzman53, 03-29-2023, 07:23 PM
                2 responses
                22 views
                0 likes
                Last Post Jazzman53  
                Started by kezyclaire, 03-29-2023, 12:01 AM
                6 responses
                32 views
                0 likes
                Last Post BartMan
                by BartMan
                 
                Started by ChrisR, Yesterday, 09:24 PM
                3 responses
                16 views
                0 likes
                Last Post ChrisR
                by ChrisR
                 
                Started by balltrader, Today, 10:06 AM
                6 responses
                31 views
                1 like
                Last Post QuantKey_Bruce  
                Working...
                X