Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time Between 2 Bars

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

    Time Between 2 Bars

    Hi,

    I've this logic in my strategy and the "diff" in time between 2 bars is printing properly. I'm trying to have a bool where if the time between bars is less than 5 seconds my bool would be false, otherwise true. I get an error code CS0019 saying I can't use "<" for TimeSpan and int for this part of the code: if (diff < 000005). How do I resolve this?

    Code:
    TimeSpan diff = Times[2][0] - Times[2][1];
    Print ("Time difference: "+diff);
    
    if (diff < 000005)
    {
    barok = false;
    }

    #2
    Try this,

    Code:
    TimeSpan diff = Times[2][0] - Times[2][1];
    Print ("Time difference: "+diff);
    
    if (diff.Seconds < 5)
    {
    barok = false;
    }
    Google is your friend.

    If you're still learning C# and/or NinjaScript,
    then google everything whenever you find
    yourself not knowing something. You'll learn
    things at a breath-taking pace, and become
    self-sufficient sooner -- you just have to get
    into the 'search the internet first' habit.

    Tips:
    For anything C# related, prefix your search string with C#.
    For anything NT related, prefix your search string with NinjaTrader.

    Just my 2˘.

    Last edited by bltdavid; 02-02-2025, 10:08 AM.

    Comment


      #3
      Thank you Sir. That worked.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      111 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      156 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      76 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      125 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      79 views
      0 likes
      Last Post PaulMohn  
      Working...
      X