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

How to get a unique time for every tick (in milliseconds)

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

    How to get a unique time for every tick (in milliseconds)

    For test i use this code for every tick on Tick1 chart:

    Code:
    Print("Tick_time:" + Time[0]);
    Result (look at picture):

    http://saveimg.ru/show-image.php?id=8cfd6dd7f2828f43646c17496343ca92


    Some amount of ticks has one Time - and this Time isn't unique for every tick.

    How to get a unique time in milliseconds for every tick?

    #2
    Hello agafon2,

    Thank you for your post.

    There is no supported method in NinjaScript to pull the milliseconds of the Tick. However, you could use StopWatch in C# with ElapsedMilliseconds to assign a unique millisecond to each Tick. There could be other routes to do this as well, each of which including the StopWatch would be unsupported methods for NinjaScript.

    For information on Stopwatch.ElapsedMilliseconds please visit the following link: http://msdn.microsoft.com/en-us/libr...liseconds.aspx

    Comment


      #3
      Can you please give a code example to get tick time by using Stopwatch.ElapsedMilliseconds

      Comment


        #4
        Hello agafon2,

        Thank you for your response.

        Unfortunately, this would be an unsupported method of achieving what you wish and therefore we do not have any code samples available.

        Comment


          #5
          Originally posted by agafon2 View Post
          For test i use this code for every tick on Tick1 chart:

          Code:
          Print("Tick_time:" + Time[0]);
          Result (look at picture):

          http://saveimg.ru/show-image.php?id=8cfd6dd7f2828f43646c17496343ca92


          Some amount of ticks has one Time - and this Time isn't unique for every tick.

          How to get a unique time in milliseconds for every tick?
          You cannot query data to a granularity that is finer that that at which it was recorded.

          Comment


            #6
            Originally posted by agafon2 View Post
            Can you please give a code example to get tick time by using Stopwatch.ElapsedMilliseconds
            That is a much larger undertaking than it first appears. For one thing, you will have to store your specially time-stamped data somewhere, if you want to use it in anything other than realtime (e.g., for backtesting et.c.,), which it seems obvious that you would. Then you also have to arrange to retrieve this data. You will have to build your own database, and query it from NT, writing the glue to interface your data seamlessly into NT calculations, and I guess, even charting.

            As a matter of curiosity, I cannot think of any reason for a retail trader to need such split second granularity to make decisions. Nobody's mouse can click that fast. Unfortunately, there is a point beyond which physical factors make increased accuracy pointless.

            If you need data with millisecond granularity to make trading decisions, then you must be running algos at those kind of speeds, which makes you a High Frequency Trader. Are you?

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rocketman7, Today, 01:00 AM
            0 responses
            1 view
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            27 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 04-23-2024, 09:53 PM
            2 responses
            74 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            193 views
            0 likes
            Last Post Hasadafa  
            Working...
            X