Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetTime method getting wrong date and time

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

    GetTime method getting wrong date and time

    Hello,

    I was wondering if anyone has encountered this problem before.

    I am getting different results with the following two statements:

    Time[0]
    BarsArray[0].GetTime(0)

    The first one returns the correct date and time. The second one, however, returns 9/9/24 @ 4pm.

    I have already checked the chart's data box (I saw on another post that this might have been the problem) and the info in there is correct.

    BR,

    Jose.

    #2
    Hello josebolde,

    Thank you for your post.

    This is because GetTime() returns the time at the specified bar index value. GetTime(0) is the time of bar with index 0. Time[0] is the time of the current bar processing.





    Please let us know if you have any further questions.

    Comment


      #3
      Hi Gaby,

      thanks for the reply! I got the GetTime() method working now. If I could just trouble you with one last detail:

      In the following code:

      protected override void OnBarUpdate()
      {
      if (CurrentBars[0] <= BarsRequiredToPlot || CurrentBars[1] <= BarsRequiredToPlot)
      return;

      SHBar = Swing(BarsArray[1],1).SwingHighBar(0,1,30) + 1;
      timeHB = BarsArray[1].GetTime(CurrentBars[1] - SHBar);

      indiceHigh = 0;
      while(Time[indiceHigh] > timeHB){
      indiceHigh = indiceHigh + 1;
      }

      Draw.VerticalLine(this,"lineaHighV",indiceHigh,Bru shes.Green);

      Print(indiceHigh);

      }​

      When I try to index a certain bar in the higher timeframe down to the lower timeframe, it seems that the variable I use (indiceHigh) goes haywire just for the first lower timeframe bar whenever a new higher timeframe bar starts. It's easier to see it visually with the vertical line that tracks the variable indiceHigh. It works fine for most bars but, when a new bar starts in the higher timeframe, it quickly moves to the right (just for one lower timeframe bar) and then it returns to the correct place.

      Currently, I am using BarsArray[0] = 1s and BarsArray[1] = 30s.

      Any help you could give would be greatly appreciated.

      Thanks and BR,

      Jose.

      Comment


        #4
        Hello,

        Please create a new thread for new inquiries, since this is unrelated to your initial request.

        Please note, any time you reply to a post, this will go to the person you are working with. Reply instead of starting a new thread when you would like to continue investigating an existing inquiry.

        Any time you create a new thread, this will create a new inquiry and a new case ticket, which will be answered by the first person available and may not be the person you are previously working with. Create a new thread instead of a reply when you have a new question that is unrelated to a previous inquiry. This will allow us to properly track each issue.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        110 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        59 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        37 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        41 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        78 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X