Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time problem

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

    Time problem

    Hi guys,
    I need some help.. I want to show the current time on chart (not only on time based chart). The point is a nonstop clock which updates itself every single seconds.

    Many thanks,
    Curi

    #2
    Hello,

    You can get the current time of your system by using DateTime.Now

    If you'd like it to update every single second, you'll have to create your own custom trigger event to call that method at the pre-defined interval you would like:



    I'm providing a reference sample which uses the TriggerCustomEvent which should help you get started:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Many thanks for your quick answer!! It sounds good.

      One more simple question: in order to visualize the current time on the chart, the right choice is DrawText methode in MyCustomHandler(object state), isn't it?

      Comment


        #4
        Yes, that should work.

        Please let me know if you have any questions.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Hi Matthew,

          I tried TriggerCustomEvent to solve my problem. But the time on the chart doesn't update every seconds.. only if something happens on the chart.
          I used that indicator what you linked. In that indicator the update works good, we get new time data on output window in every seconds.
          I modified the Print methode to DrawTextFixed:

          Code:
          		private void MyCustomHandler(object state)
          		{
          
                                  //Print("\tTime: " + DateTime.Now);
          			//Print("\tTimer Interval: " + state.ToString() + "ms");
          			
          			DrawTextFixed("tag",DateTime.Now.ToString(),TextPosition.TopLeft);
          		}
          What can I do for the persistent update?

          Comment


            #6
            You'd need to add some logic in your MyCustomHandler to check the last time that the timer updated, and then call the plot method to update via ChartControl.ChartPanel.Invalidate();

            Code:
            		private void MyCustomHandler(object state)
            		{
            			if(DateTime.Now.Subtract(pcTime).Seconds >= 1)
            			{
            				ChartControl.ChartPanel.Invalidate();
            				pcTime = DateTime.Now;
            			}
            			
            			DrawTextFixed("time", pcTime.ToString("HH:mm:ss"), TextPosition.TopRight);
                    
            		}
            I've attached a working copy which should help clarify.
            Attached Files
            MatthewNinjaTrader Product Management

            Comment


              #7
              Thank you very much!!! This is so useful!!

              Comment

              Latest Posts

              Collapse

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