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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          173 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          91 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          129 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          208 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          186 views
          0 likes
          Last Post CarlTrading  
          Working...
          X