![]() |
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 |
|
Senior Member
Join Date: Feb 2010
Posts: 150
Thanks: 1
Thanked 1 time in 1 post
|
To test for the value of the first tick of the day when charting 5 minute bars, I set COBC = false and use:
ToTime(Time[0]) == 93500 && FirstTickOfBar What would I replace the ToTime(Time[0]) function with when using days bars as I don't think that I can use 161500 because the bars are marked with days instead of minutes. If it's some kind of date function that I need, I'd be appreciative if you could also give me the exact format that the date has to be in. Thanks, Stephen |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Mar 2011
Location: Denver, CO
Posts: 103
Thanks: 0
Thanked 0 times in 0 posts
|
Hello Stephen,
Thank you for your post. If you are working with daily bars, you only need to check FirstTickOfBar since there is only one daily bar in the session. No additional date checking should be needed. Give this a try and let me know if I can assist with anything else.
Dexter
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Feb 2010
Posts: 150
Thanks: 1
Thanked 1 time in 1 post
|
Thanks.
My strategy executes on day bars and depend on the opening price of the day (which you've shown me how to get). For backtesting, I'm going to need 1 minute bars (I don't have tick data going back far enough). I read the SampleIntrabarBacktest program. I realize that I have to execute buys and sells on the 1 minute bars, but do I have to explicitly reference the one minute bars when I need intraday data, e.g., for FirstTickOfBar when I'm doing my logical tests as they relate to day bars or will the backtesting program just have access to that 1 minute data and use it as appropriate. On the day bars, I just need to test the first tick of the day relative to the previous day's high and low and test prices during the day for their relationship to the previous day's high and low. |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Mar 2011
Location: Denver, CO
Posts: 103
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
Thank you for your reply. Yes, when you need to reference data from the one minute bars, you need to specify such. This can be done in an if(BarsInProgress == 1) section. You could also use BarsArray[1], this is assuming your 1 minute series is the first additional timeframe added. OnBarUpdate is called for each timeframe added, with the primary being index 0. Since you are working with current day open high & low and previous day's high and low these two indicators may be of help: CurrentdayOHL - http://www.ninjatrader.com/support/h...nt_day_ohl.htm PriorDayOHLC - http://www.ninjatrader.com/support/h...r_day_ohlc.htm You can access their calculated values so this may save you some effort. You may be able to just use a single timeframe in your code, and use these indicators for the day data. Just let me know if I can assist with anything else
Dexter
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Feb 2010
Posts: 150
Thanks: 1
Thanked 1 time in 1 post
|
Just to check that I understand this. Are these equivalent:
EnterLong(1, 1, "Long: 1min"); if (BarsInProgress == 1) EnterLong(1,"Long: 1min"); |
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Mar 2011
Location: Denver, CO
Posts: 103
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Stephen,
They are different, the first one would run on both timeframes added. For example, if you are running on a 5 minute chart, and have added a 1 minute period via Add(), OnBarUpdate will be called for each time frame, on each tick if COBC = false. Checking BarsInProgress will make the logic only apply to a certain timeframe. Please let me know if you have any other questions.
Dexter
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Last Day in testing range not accessbile? | Beauregard | Strategy Development | 3 | 01-14-2011 07:37 AM |
| Back-testing difference (single day vs multiple days) | Mikefra | Strategy Analyzer | 5 | 12-27-2010 11:46 AM |
| Testing Slope of 21-Day EMA | StarBright2009 | General Programming | 1 | 09-24-2009 06:42 AM |
| Visual testing tick by tick on chart | peterdias77 | Strategy Analyzer | 1 | 01-28-2009 06:08 AM |
| backtesting vs. forward testing like night vs. day | andrewbee | Strategy Development | 15 | 01-04-2008 10:48 PM |