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

Odd results with time differences

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

    Odd results with time differences

    I was exploring the use of the ToTime function to get some time differences between ticks. When I put the following indicator on a one minute chart of today's YM front month contract I find that it outputs the value 100 for time differences between bars and when the hour rolls over it reads 4000...

    Plot0.Set(ToTime(Time[0] - ToTime(Time[1]));

    What units is that supposed to be in? The problem at the hour rollover appears to be a bug unless I've misapplied something...

    On a tick chart it seems to read out in seconds and i get the 4000 reading at the hour rollover as well...

    #2
    Please review the Help Guide section for clear example of what is returned from the ToTime() method. Its an integer representation and not something you should use to calcualte the difference.



    Try

    Plot.Set(Time[0].Subtract(Time[1]).TotalSeconds);

    More information on DateTime methods/properties - http://msdn.microsoft.com/en-us/libr...e_members.aspx
    RayNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by GussJ, 03-04-2020, 03:11 PM
    15 responses
    3,270 views
    0 likes
    Last Post xiinteractive  
    Started by Tim-c, Today, 02:10 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    2 views
    0 likes
    Last Post Taddypole  
    Started by chbruno, 04-24-2024, 04:10 PM
    4 responses
    51 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    10 responses
    403 views
    1 like
    Last Post beobast
    by beobast
     
    Working...
    X