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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      61 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      149 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      99 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      286 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X