Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time List

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

    Time List

    Hello

    I'm printing some values from my indicator and I run into something I don't get:
    In the code below, the Time print sometimes is not accurate, as it prints (in at least one occasion that I found) the time of the previous arrow that was actually removed by the script
    I found that replacing " RebUpBarTime[a-1] " with " Time.GetValueAt(RebUpBar[a-1]) " gives me the right Time print, but I don't understand why is that?

    Code:
    if (i == Scan || ToTime(Time[0]) == endTime)
    {        
         if (triggerUp)
            Print (RebUpBarTime[a-1] + "    |    Rebound Up    |    " + RebUpBar[a-1] + "    |    " + upRange + "    |    " + upStop + "    |    " + (UpHeatRb.Count != 0 ? UpHeatRb.Min() : upLoss) + "    |    " + upLoss + "    |    " + i + "    |    " + c);                    
    
      }
    ..............
    if ((a == 0 ? true : CurrentBar != (RebUpBar[a-1] + 1)) && (Math.Min((Close[0] - Low[0]), (Open[0] - Low[0])) / (High[0] - Low[0])) * 100 >= WickPct 
    
                        && Low[0].ApproxCompare(MIN(Low, 5)[1]) < 0 && Close[0] > Low[1] + CloseOffset * TickSize)
    {                    
         RebUpBar.Add(CurrentBar);                    
         RebUpBarTime.Add(Time[0]);
         Draw.ArrowUp(this, "Rebound Up = " + RebUpBar[a], true, 0, Low[0] - 2 * TickSize, Brushes.Lime);
        .............
         a++;
    }

    #2
    Hello itrader46,

    Thank you for your note.

    Within what method is this code? OnBarUpdate, or somewhere else?

    As you probably know, you can quickly look up the bar value on the chart by calling a PriceSeries<T> barsAgo indexer, e.g., Time[0].

    However, the internal indexer and pointers about the barsAgo value are only guaranteed to be correctly synced and updated during a market data event. As a result, you should favor using the absolute GetValueAt() methods during events which are not driven by price.

    So, basically, using Time[0] within OnBarUpdate should return the time of that bar close, but it's not guaranteed to be synced other places, so GetValueAt() will work instead in those cases.

    Please let us know if we may be of further assistance to you.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    57 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    78 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    39 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    101 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    61 views
    0 likes
    Last Post PaulMohn  
    Working...
    X