Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    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
        BertrandNinjaTrader Customer Service

        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 samish18, Yesterday, 10:13 AM
          1 response
          22 views
          0 likes
          Last Post NinjaTrader_Eduardo  
          Started by Austiner87, Today, 05:02 PM
          0 responses
          5 views
          0 likes
          Last Post Austiner87  
          Started by tonynt, 05-21-2019, 06:27 AM
          10 responses
          530 views
          1 like
          Last Post fiendtrades  
          Started by awwenzovs, Today, 08:03 AM
          2 responses
          15 views
          0 likes
          Last Post NinjaTrader_Eduardo  
          Started by Ashkam, 04-29-2024, 09:28 AM
          4 responses
          44 views
          0 likes
          Last Post Ashkam
          by Ashkam
           
          Working...
          X