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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    53 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    34 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    100 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    180 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    170 views
    0 likes
    Last Post CarlTrading  
    Working...
    X