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 M_ichel, 01-29-2023, 11:17 AM
                4 responses
                58 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by rc5781, 06-16-2022, 07:18 AM
                4 responses
                77 views
                0 likes
                Last Post RoboTrader  
                Started by carnitron, 09-20-2022, 10:35 AM
                13 responses
                221 views
                0 likes
                Last Post jeronymite  
                Started by Douglee, Yesterday, 08:00 PM
                0 responses
                49 views
                0 likes
                Last Post Douglee
                by Douglee
                 
                Started by DT215, Yesterday, 07:49 PM
                0 responses
                48 views
                0 likes
                Last Post DT215
                by DT215
                 
                Working...
                X