NinjaTrader Support Forum  
X

Attention!

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


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 04-18-2011, 12:00 PM   #1
sgordet
Senior Member
 
Join Date: Feb 2010
Posts: 150
Thanks: 1
Thanked 1 time in 1 post
Default Testing first tick of day bar

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
sgordet is offline  
Reply With Quote
Old 04-18-2011, 12:16 PM   #2
NinjaTrader_Dexter
NinjaTrader Customer Service
 
NinjaTrader_Dexter's Avatar
 
Join Date: Mar 2011
Location: Denver, CO
Posts: 103
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
NinjaTrader_Dexter is offline  
Reply With Quote
Old 04-18-2011, 01:03 PM   #3
sgordet
Senior Member
 
Join Date: Feb 2010
Posts: 150
Thanks: 1
Thanked 1 time in 1 post
Default

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.
sgordet is offline  
Reply With Quote
Old 04-18-2011, 01:26 PM   #4
NinjaTrader_Dexter
NinjaTrader Customer Service
 
NinjaTrader_Dexter's Avatar
 
Join Date: Mar 2011
Location: Denver, CO
Posts: 103
Thanks: 0
Thanked 0 times in 0 posts
Default

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
NinjaTrader_Dexter is offline  
Reply With Quote
Old 04-18-2011, 01:51 PM   #5
sgordet
Senior Member
 
Join Date: Feb 2010
Posts: 150
Thanks: 1
Thanked 1 time in 1 post
Default

Just to check that I understand this. Are these equivalent:

EnterLong(1, 1, "Long: 1min");

if (BarsInProgress == 1)
EnterLong(1,"Long: 1min");
sgordet is offline  
Reply With Quote
Old 04-18-2011, 02:20 PM   #6
NinjaTrader_Dexter
NinjaTrader Customer Service
 
NinjaTrader_Dexter's Avatar
 
Join Date: Mar 2011
Location: Denver, CO
Posts: 103
Thanks: 0
Thanked 0 times in 0 posts
Default

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.
NinjaTrader_Dexter is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 09:13 AM.