Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical Bars

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

    Historical Bars

    I am writing a strategy and would like to "look up" information on a stock in a previous time during the OnBarUpdate method.

    To accomplish this, I am first adding the stock in the Initialize method:

    Code:
    Add("MYSTOCK", PeriodType.Minute, 15);
    Then, I am attempting to look up the price of the stock 50, 15 minute "ticks" ago using:

    Code:
    var bar = CurrentBar - 50;
    var bars = BarsArray[0];
    			
    double oldPrice =  bars.GetOpen(bar);
    This seems to work ok, but it also seems to be including many "ticks" that are not during the active trading day (pre-market, post-market, weekends, etc). Is there any way to ensure that the bars I am using are ONLY from active trading hours?

    #2
    Think I found it

    I think I had the wrong template selected for my stock indicator... does that seem correct?

    Comment


      #3
      Thanks for letting us know - yes, that sounds correct - as the primary template would define the hours in most cases of the setup.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      67 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      36 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      59 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X