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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    571 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    331 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    549 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    549 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X