Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by andrewtrades, Today, 04:57 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    5 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    7 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X