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 kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      57 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      39 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      45 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      35 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      153 views
      0 likes
      Last Post SalmaTrader  
      Working...
      X