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

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
            Paul H.NinjaTrader Customer Service

            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
                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rhyminkevin, Today, 04:58 PM
                    3 responses
                    48 views
                    0 likes
                    Last Post Anfedport  
                    Started by iceman2018, Today, 05:07 PM
                    0 responses
                    5 views
                    0 likes
                    Last Post iceman2018  
                    Started by lightsun47, Today, 03:51 PM
                    0 responses
                    7 views
                    0 likes
                    Last Post lightsun47  
                    Started by 00nevest, Today, 02:27 PM
                    1 response
                    14 views
                    0 likes
                    Last Post 00nevest  
                    Started by futtrader, 04-21-2024, 01:50 AM
                    4 responses
                    50 views
                    0 likes
                    Last Post futtrader  
                    Working...
                    X