Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

timing arithmetic

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

    timing arithmetic

    I am trying to set up a time counter from the opening bell.
    so, I code:
    if (TimeTo(Time[0]- 93000)< 5000
    {
    do this
    }
    debbuging the code I found
    95900-93000= 2900 (perfect!! 29 minutes has passed)
    and then:
    100000-93000 =7000 (not right)
    what am I doing wrong???

    #2
    Originally posted by dafonseca View Post
    I am trying to set up a time counter from the opening bell.
    so, I code:
    if (TimeTo(Time[0]- 93000)< 5000
    {
    do this
    }
    debbuging the code I found
    95900-93000= 2900 (perfect!! 29 minutes has passed)
    and then:
    100000-93000 =7000 (not right)
    what am I doing wrong???
    A LOT

    compare the same times

    Comment


      #3
      Originally posted by dafonseca View Post
      I am trying to set up a time counter from the opening bell.
      so, I code:
      if (TimeTo(Time[0]- 93000)< 5000
      {
      do this
      }
      debbuging the code I found
      95900-93000= 2900 (perfect!! 29 minutes has passed)
      and then:
      100000-93000 =7000 (not right)
      what am I doing wrong???
      You are treating Modulo60 arithmetic like decimal arithmetic. Use standard c# DateTime() methods, or else (more cantankerously), use proper Modulo60 arithmetic.

      Comment


        #4
        Originally posted by koganam View Post
        You are treating Modulo60 arithmetic like decimal arithmetic. Use standard c# DateTime() methods, or else (more cantankerously), use proper Modulo60 arithmetic.
        I googled that to make sure I missed something in skewl

        #1 ad (#1 result was in spanish)

        Módulo 60 Unipessoal Lda
        Directions
        Wood Contractor
        Address: R. Monte da Nespereira 4, 4770, Portugal
        Phone:+351 252 315 392


        I missed something in skewl

        But I remember the old guy who taught me MOD in real life application... Thanks to D.R.

        Comment


          #5
          Originally posted by sledge View Post
          I googled that to make sure I missed something in skewl

          #1 ad (#1 result was in spanish)

          Módulo 60 Unipessoal Lda
          Directions
          Wood Contractor
          Address: R. Monte da Nespereira 4, 4770, Portugal
          Phone:+351 252 315 392


          I missed something in skewl

          But I remember the old guy who taught me MOD in real life application... Thanks to D.R.
          If you do not remember Modular Arithmetic, then you really must have been paying too much attention to something else in skewl. Maybe you were looking for love?

          ref: https://en.wikipedia.org/wiki/Modular_arithmetic

          It pretty much uses a clock as the quintessential reference. Heh heh.

          Comment


            #6
            Hello dafonseca,

            Thanks for your post.

            If you have not already resolved the issue, please clarify what you are trying to do. In reading your original post I wondered if you were trying to have an action occur during a certain time period or at a certain time period.

            Here is some further info on C# datetime: http://www.dotnetperls.com/datetime

            Comment


              #7
              I got the idea and understand my mistake. I will spend some time working on C# datetime, Some code example on NT would save some time.
              Let you know.

              Comment


                #8
                My link contained a code sample on the first reply

                Comment


                  #9
                  lets suppose i want to use your snippet code below. but I want ToTime( 09, 30, 00) and ToTime( 16, 00, 10) to be defined as private variables which can be changed.
                  how this beginOpentrading would be declared? I trie DateTime but I got some errors.
                  Another question would be: How can I add 60 minutes to ToTime(9,30,00) and get ToTime(10,30,00).

                  protected override void OnMarketData(MarketDataEventArgs e)
                  {
                  if (ToTime(Time[0]) < ToTime( 09, 30, 00) || ToTime(Time[0]) > ToTime( 16, 00, 10)) return;
                  }

                  Comment


                    #10
                    Hello dafonseca,

                    Using the ToTime( 09, 30, 00) example, you can change the specific hours/minutes to integer variables such as : ToTime(starthour, startMinute, 00)

                    Here is a link to one of our reference samples that shows manipulating datetime objects: http://ninjatrader.com/support/forum...ad.php?t=19292

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    558 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    324 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    545 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    547 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X