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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    161 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    312 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X