Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar Speed Timer

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

    Bar Speed Timer

    Hi folks. I'm trying to migrate a barspeed indicator from NT7 to NT8. Once part of the code on NT7 is
    Code:
        TimeSpan timer = Time[0] - Time[1];
    but I keep getting error on NT8 that "Cannot implicity convert type 'double' to System.TimeSpan.

    Thoughts?

    #2
    Hello ginx10k,

    I don't see a problem with this specific code, the error you provided means that you are trying to set a double as a TimeSpan. Something that would generate that would be:

    Code:
    TimeSpan timer = Close[0];
    If you double click the error message and not the CSxxxx number, it should take you to the line or general area of the script which has the error.

    I look forward to being of further assistance.

    Comment


      #3
      Hi, thanks for response. I've attached the indicator. I just can't see why it won't compile. please help with these errors. Thanks!
      Attached Files

      Comment


        #4
        Hello ginx10k,

        It looks like you made a plot named Time, there is already a property named Time so you remapped it to a double.

        You would need to change the name of your plot to be something unique and not already used like MyTime as an example.

        I look forward to being of further assistance.

        Comment


          #5
          I get the following error when applying my bar timer:
          "Error on calling 'OnBarUpdate' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."
          My code is:
          protected override void OnBarUpdate()
          {BD[0] = (Time[0]-Time[1]).TotalSeconds;}
          searched this thread for an answer before posting. Just looking to subtract bar close times and plot. Thank you!

          Comment


            #6
            Hello Kicks.Spin,

            Thats likely because you are using Time[1] before 1 BarsAgo is available.

            You can add
            if(CurrentBar < 1) return; before that and it should avoid that message.


            I look forward to being of further assistance.

            Comment


              #7
              Thanks Jesse. That worked.

              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