![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Jun 2008
Posts: 62
Thanks: 0
Thanked 3 times in 3 posts
|
Hi there,
I want to know how to control the start times of bars NT trader uses as this can have very large impacts to do with opening and closing times of markets. My specific question relates to a strategy. Let's say in the init function we have added several data series to the strategy, for example: Add(PeriodType.Minute, 240); Let's also say, imported data into NT is one minute data, and imported correctly with reference timezone -5 (eastern USA). When the strategy runs, in particular the OnBarUpdate() function, I check for which bar in particular is calling the function, eg: if (BarsInProgress == 2) // run this for our **** minute timeframe only { // stuff to run for 3rd dataseries... } What I need to be sure of, or force NT to do somehow, is to define what the default start time of bars should be. For example, let's say for the 240 minute bars I wanted to have them starting at 0200, 0600, 1000, 1400, 1800, 2200 each day, such that when I call the open of bar[0] each day, I would be getting the price at 0200, and the close would be the price just before the next open (say around 0559) This is very important for the intraday timeframe bars. thanks in advance |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
PolarBear, NT would generally stamp the bars witht the closing time - what times are used is controlled by the session template applied to your charts / series. You can edit / create templates with custom times as needed yourself under Tools > Session Manager.
http://www.ninjatrader.com/support/h...on_manager.htm
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Jun 2008
Posts: 62
Thanks: 0
Thanked 3 times in 3 posts
|
Hi thanks for the Reply. can you please clarify which close you are referring to? I'm using1 minute data, and talking about 240 bars that I create in the strategy as mentioned below
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2009
Location: Denver, CO
Posts: 8,117
Thanks: 249
Thanked 418 times in 415 posts
|
Hi Polar Bear,
The closing time Bertrand mentions is when the bars ends. So a 240 minute bar time stamped at 12:00 PM consists of trading activity between 8:00 AM - 11:59:59. More information on this is available here: http://www.ninjatrader.com/support/h..._are_built.htm The starting and ending time of the series is controlled by the session template selected. For added series, see below the rules that determine which session template is used: If a multi-series script adds an additional Bars object that already exists on the chart, the script will use the preexisting series instead of creating a new one to conserve memory. This includes that series' session template as applied from the chart. If the Bars object does not exist on the chart, the session template of the added Bars object will be the session template of the primary Bars object. If the primary Bars object is using the "<Use instrument settings>" session template then the additional Bars objects will use the default session templates as defined for their particular instruments in the Instrument Manager.
Ryan M
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Jun 2008
Posts: 62
Thanks: 0
Thanked 3 times in 3 posts
|
Thanks. In relation to the quote below in your post, if primary bars are 1 minute bars, and I add a 240 minute (PeriodType.Minute, 240) is that counted as the same as the primary (as it's based on 1 minute data) or as a new bar object? I suspect a new one, but can you confirm.
Also, I know what closing time means, I was referring to how you control it, which you have tried to explain. I don't quite understand though, because from the definition given, it seems that the newly created 240 minute bar object will "be the session template of the primary Bars object.". What does this mean?? the open and close of 1 minute data will be every minute, how does this let me control when the open and close of the 240 minute bar will be. From the session manager and related help, from what I can see it seems to just be controlling the start / end time each day. How does this then effect the 240 minute bar I'm creating? Perhaps can you reply with a specific solution for the 240 minute case, rather than copy and paste from the manual which I have tried to understand but it is still unclear. thanks. |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
|
It would be then using the same hours as the primary series, as it's the same instrument for your chart / script.
The session template used will define what time range of data is generally available on an intraday chart in NinjaTrader. Let's get to a more practical example to help simplify matters : you would control the start and end time of the bars by defining when your session template would enable the bars to be created for the day.... If you define Template1 starting your session at 8 AM >> the 240 min bar would close at 11:59:59 If you define Template2 starting your session at 8:30 AM >> the 240 min bar would close at 12:29:59 Hope that helps,
Bertrand
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| No data for first second on added time series | gomifromparis | General Programming | 13 | 05-23-2011 03:02 AM |
| Limiting time-frame of an added bars object | miker | General Programming | 4 | 02-01-2011 04:15 PM |
| Access Price Data for Instrument not Added as Series | upshon | General Programming | 6 | 01-19-2011 03:18 AM |
| Bars.BarsSinceSession before Session Start time | mefTrader | General Programming | 4 | 04-12-2010 02:34 PM |
| controlling appearance of bars | jeffg | Charting | 1 | 06-15-2007 02:49 PM |