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 SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    32 views
    0 likes
    Last Post SalmaTrader  
    Started by CarlTrading, 07-05-2026, 01:16 PM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 06-17-2026, 10:32 AM
    0 responses
    12 views
    0 likes
    Last Post CaptainJack  
    Started by kinfxhk, 06-17-2026, 04:15 AM
    0 responses
    18 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 06-17-2026, 04:06 AM
    0 responses
    20 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X