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 AaronKoRn, Today, 09:49 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post AaronKoRn  
                    Started by carnitron, Today, 08:42 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post carnitron  
                    Started by strategist007, Today, 07:51 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post strategist007  
                    Started by StockTrader88, 03-06-2021, 08:58 AM
                    44 responses
                    3,975 views
                    3 likes
                    Last Post jhudas88  
                    Started by rbeckmann05, Today, 06:48 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post rbeckmann05  
                    Working...
                    X