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 > Application Technical Support > Strategy Analyzer

Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer.

Reply
 
Thread Tools Display Modes
Old 08-21-2007, 03:23 AM   #1
jonesr227
Junior Member
 
Join Date: Aug 2007
Posts: 21
Thanks: 0
Thanked 0 times in 0 posts
Default Backtesting bar interval

I have a basic question. It appears that the only historical data that I can load must be in 1 minute bars. Is this correct? The manual appears to say this; and fiurthermore I've had no luck trying to load 2 minute bar data.

Rick
Last edited by jonesr227; 08-21-2007 at 03:28 AM.
jonesr227 is offline  
Reply With Quote
Old 08-21-2007, 03:31 AM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

>> It appears that the only historical data that I can load must be in 1 minute bars.
Incorrect, you can run your strategy on any minute series you'd like. Just (a) run it on a 2 minute chart or (b) start it on a 2 minute series in the strategies tab or (c) backtest it on a 2 minute series using the strategy analyzer.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 08-21-2007, 03:52 AM   #3
jonesr227
Junior Member
 
Join Date: Aug 2007
Posts: 21
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Dierk View Post
>> It appears that the only historical data that I can load must be in 1 minute bars.
Incorrect, you can run your strategy on any minute series you'd like. Just (a) run it on a 2 minute chart or (b) start it on a 2 minute series in the strategies tab or (c) backtest it on a 2 minute series using the strategy analyzer.
OK, so now I need to know how I can import 2 minute data into NT. I have successfully done this for 1 minute data, but following the same procedure for 2 minute data resulted in the error message "Instrument is not supported by repository". Prior to this I did use the instrument manager to set up the new name of the data that I hoped to import. Here again, I'm confused by the fact that there appears to be little lattitude in choosing instrument names. For example, I had previously imported 1 minute ER2 data and I gave it the name "ER2 09-07"; now for 2 minute data for ER2 I gave it a name "ER2 03-07" but this resulted in the above error message.
Can I give more descriptive names such as "ER2_1min" and "ER2_2min"?
I haven't been able to find out how.
jonesr227 is offline  
Reply With Quote
Old 08-21-2007, 03:58 AM   #4
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Let's not confuse things:

a) Instrument names have nothing to do with data series. As you have imported 1 minute bare series for ER2 09-07, any (!) minute series, including 2 minute series for ER2 09-07 is readily available and you can run tests on it a per my post below.

b) If you want to run test on the ER2 03-07 you need to import data for that instrument as well, since it just a different instrument.

c) Before testing any instrument I suggest you add it to your instrument list by: Tools->Instrument manager. This is a limitation of NT6 and will be come by fall time.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 08-21-2007, 04:15 AM   #5
jonesr227
Junior Member
 
Join Date: Aug 2007
Posts: 21
Thanks: 0
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Dierk View Post
Let's not confuse things:

a) Instrument names have nothing to do with data series. As you have imported 1 minute bare series for ER2 09-07, any (!) minute series, including 2 minute series for ER2 09-07 is readily available and you can run tests on it a per my post below.

b) If you want to run test on the ER2 03-07 you need to import data for that instrument as well, since it just a different instrument.

c) Before testing any instrument I suggest you add it to your instrument list by: Tools->Instrument manager. This is a limitation of NT6 and will be come by fall time.

I understand that having imported 1 minute data that I can now run any (integral multiple) bar interval. Therefore I understand your point (a) above. Also (as I mentioned in my prior post) I did use the Instrument Manager to add the instrument name; so I also understand your point (c) above.

Point (b) however appears to require qualification. When you say "If you want to run test on the ER2 03-07 you need to import data for that instrument as well", apparently implicit in this is that this new data must be in 1 minute bars. Which leads me to my very original question: "It appears that the only historical data that I can load must be in 1 minute bars. Is this correct?" So the answer is in fact yes. Sorry for belaboring this but I need to have a clear understanding of this.
jonesr227 is offline  
Reply With Quote
Old 08-21-2007, 05:26 AM   #6
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

ER2 09-07 and ER2 03-07 are two different instruments, like MSFT and DELL are two different instruments.

Not sure what you mean by "loading data": if you mean importing then yes, you only can import 1 minute series (and not 2 minute series), if you mean running a strategy then no, and my post below stands.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 08-21-2007, 06:12 AM   #7
jonesr227
Junior Member
 
Join Date: Aug 2007
Posts: 21
Thanks: 0
Thanked 0 times in 0 posts
Default

Dierk,

Thank you very much for your help.

As I learn about NT, I was baffled to find in regards to data that ,
(at present):
1) only 1 minute interval bars can be imported,
2) only specific names can be used with the data.

By the way, (not withstanding the above issues) I think NT is a terrific
product. I'm actually hoping that it will replace my current backtester.
(There's no longer any reason to use a backtester that uses interpreted code).
jonesr227 is offline  
Reply With Quote
Old 08-21-2007, 06:15 AM   #8
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

1) You can import 1 minute, 1 tick and 1 day series. All other series are created by NT internally. No need to import anything else.
2) Not sure what you mean by "only specific names can be used with the data".
NinjaTrader_Dierk is offline  
Reply With Quote
Old 09-15-2007, 03:57 PM   #9
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 329
Thanks: 0
Thanked 11 times in 8 posts
Default Tick Data in Back Testing

I am testing a strategy and trying to see if it can be improved using a trailing stop. I'm using a 377 tic interval on the ER2 (the september 07 contract). I'm using mirus/zenfire for my historical data. I find that if I use a low value of for the trail interval (say 2 tics) I get fantastic results for the strategy but when I run those same values in real-time, I get terrible results. I understand that backtesting versus real-time will not be the same, but I'm struggling to understand how I can use backtesting to improve a strategy when the delta between back versus real is so huge. It must be the way a tick bar is built in the historic data. Can you provide more detail about how that tic is built. If I run a 377 tick interval in backtesting, are there 377 tics, all time-stamped inside that bar or is there a different methodology. If the strategy can't look "inside" a bar, why do I get trailing stop hits inside the bar the position is taken in? I have the strategy set to execute on the bar close, and all my positions start on the open of the next bar.
daven is offline  
Reply With Quote
Old 09-15-2007, 04:17 PM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Hi Daven,

When you are backtesting there is only one bar timestamped and not 377 ticks inside that bar with each timestamped. This is why we can't "look" inside the bar for more clarity. You get a trailing stop because it just assumes you would have gotten filled at x level. It looks at the OHLC and determines if sometime within that bar you would have been stopped out and it will do so at your trailing stop price. The reason all your positions start at the beginning of the next bar is related to the "look" inside limitation. Because the only time you would know the OHLC of a bar is at the end of the bar, the only time you can act is right now and not in the past. Right now means the start of the new bar. Hope that helps clarify things.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-15-2007, 05:18 PM   #11
daven
Senior Member
 
Join Date: Mar 2006
Location: Bellingham, WA , USA
Posts: 329
Thanks: 0
Thanked 11 times in 8 posts
Default Inside BackTesting Bar Details

Josh,
Thanks for that clarification. That explains what I've been seeing in testing versus reality. Is there a way to run a strategy so that the strategy entry is executed on the close of a bar, but any trailing or stop positions would be executed within a bar, (not wait for the bar to close)?
Daven
daven is offline  
Reply With Quote
Old 09-15-2007, 05:32 PM   #12
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Unfortunately there is no steadily available method to do so. This is the reason why you cannot just backtest your strategy. You also need to forward test it. Personally, the way I forward test my strategy is from replay files.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-15-2007, 11:46 PM   #13
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Excuse my previous comment. I misunderstood your question. You can set CalculateOnBarClose == true to have your strategy entry only execute on the bar close. You can then use SetTrailStop() to manage your stops. Even when CalculateOnBarClose == true the SetTrailStop() will be updated tick by tick so it will exit for you within the bar.

http://www.ninjatrader-support.com/H...TrailStop.html
NinjaTrader_Josh is offline  
Reply With Quote
Old 10-12-2007, 07:38 AM   #14
kgillis23
Member
 
Join Date: May 2007
Location: West Jordan, Utah
Posts: 61
Thanks: 0
Thanked 0 times in 0 posts
Default

May I jump in here. I believe I have been trying to do what daven is talking about. Using single tick historical data I am attempting to backtest a strategy that is based on 30 minute indicators. I open a position correctly at the close of a 30 minute bar, but it appreas that even using SetTrailingStop() my position is not updated until the close of the next 30 minute bar. This happens if CalculateOnBarClose is true or false.

Do I misunderstand?

Thanks
kgillis23 is offline  
Reply With Quote
Old 10-12-2007, 11:07 PM   #15
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Hi kgillis23,

During backtesting you will enter the trade on the next bar after you place your order. This is the case for normal entries and exits via the EnterLong() ExitShort() methods. Technically speaking, the order is placed and filled at the open of the next bar because the close of the current bar is already past history and you can't affect history.

In regards to the SetTrailStop() method. It sends orders that will be executed on the bar it is triggered even in backtesting. It will not wait for the bar to close to exit your already existing position. The logic behind this is because if the stop price is triggered anywhere during the bar it would have closed right there. Does that make sense? The SetTrailStop() is unaffected by which setting you have CalculateOnBarClose at while regular entry and exit methods are affected by it.

Hope that clarifies things.
NinjaTrader_Josh 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
Backtesting Algorithm dgregor5 Strategy Analyzer 5 08-10-2007 02:11 AM
Display Update Interval (sec) question. higler Charting 1 07-30-2007 06:32 AM
Dynamic base pointer or time reference for secondary time interval ct Strategy Development 11 06-20-2007 02:27 PM
Backtesting AO76 Strategy Development 2 05-23-2007 09:48 AM
intraday time interval rally7 Miscellaneous Support 2 05-14-2007 12:09 PM


All times are GMT -6. The time now is 10:33 PM.