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 NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      86 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      151 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      79 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      52 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      59 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X