Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ToTime doenst record seconds?

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

    ToTime doenst record seconds?

    Hi,

    I am using the ToTime as i want to display different color text for 5 seconds after an update from another indicator... The issue is that the color changes for an extended period of time, maybe 1 or two minutes.... when my code only specifies an additional 5 seconds (i thought)

    So i started mucking around the the Print function and have found that ToTime doesnt record seconds, only minutes despite the fact it clearly has the digits included for the seconds in the format HHMMSS...... The output always has 00 for the seconds portion irrespective of the seconds when it was captured.....

    How can i get my condition to only last for 5 seconds?

    Thanks for any help.


    if (GeoKingV1(false,false,false, Dev).LastTimeAlerted()+000005 > ToTime(Time[0]))
    {
    graphics.DrawString("| GeoKing Multi v1 - Dev = "+Dev,textfontHeader, textbrushOn,new Point(bounds.Left+(0+LeftShift),bounds.Bottom-(140+BottomShift)));
    }
    else
    {
    graphics.DrawString("| GeoKing Multi v1 - Dev = "+Dev,textfontHeader, textbrushGreen,new Point(bounds.Left+(0+LeftShift),bounds.Bottom-(140+BottomShift)));
    }

    #2
    Marty, what chart / timeframe are you running this on? Time[0] is basically the bars timestamp, so on a 1 minute for example > there would be no seconds portion to deal with here. You could access the current PC clock time via DateTime.Now and compare a previous saved time from it for your task.
    Last edited by NinjaTrader_Bertrand; 05-27-2012, 12:20 PM.

    Comment


      #3
      Great.. will look into it.. thanks again Bertrand.

      Comment


        #4
        For time differences, a C# TimeSpan is also helpful - http://www.dotnetperls.com/timespan

        Comment


          #5
          All done, works a charm! Thanks.



          For anyone who wanted to see the working code, see below



          TimeSpan span = new TimeSpan(0, 0, 0, 3, 0); // this is 3 seconds

          if (GeoKingV1(false,false,false, Dev).LastTimeAlerted()+span > DateTime.Now) //LastTimeAlerted is a DateTime variable assigned in another indicator.
          {
          graphics.DrawString("| GeoKing Multi v1 - Dev = "+Dev,textfontHeader, textbrushOn,new Point(bounds.Left+(0+LeftShift),bounds.Bottom-(140+BottomShift)));
          }
          else
          {
          graphics.DrawString("| GeoKing Multi v1 - Dev = "+Dev,textfontHeader, textbrushGreen,new Point(bounds.Left+(0+LeftShift),bounds.Bottom-(140+BottomShift)));
          }

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          331 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          549 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X