Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting bars between a certain time period using GetBar

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

    Getting bars between a certain time period using GetBar

    Hello,

    I am trying to get last 1 min bar using GetBar function. I am using following piece of code for this purpose but it returns me all the bars during that day.

    For example if
    startDate = 2/12/2014 3:00:00
    endDate = 2/12/2014 3:01:00

    It returns all 1 min bars for 2/12/2014.

    Code:
    public Bars GetCurrentBar(string instrument, int period, DateTime startDate, DateTime endDate)
    {
    	Bars newBars = Data.Bars.GetBars(Cbi.Instrument.GetObject(instrument), new                      Period(PeriodType.Minute, period, MarketDataType.Last), startDate, endDate, Data.Bars.GetSession(Instrument, ""), Data.Bars.SplitAdjust, Data.Bars.DividendAdjust);
    	
    	return newBars;			
    }
    Please advise how can I get the bars between a certain time period?

    Thanks,

    #2
    tazz90, that would be unfortunately not a supported / documented method but from my experience I would expect that outcome since it would depend on the session you pass in for loading between your from / to dates for the call.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    83 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    45 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    65 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Working...
    X