![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
Hello,
First off, my users have been successfully using Ninja Trader to simultaneously backtest complex strategies on a massive number of contracts from many exchanges in many time zones, and think your product is fantastic. They are having no problems at all backtesting their strategies on 1 minute bars, but are having a problem simultaneously testing many contracts on 15 minute bars when the contracts have different open times. They would like the 15 minute bars for the markets that open at 7:20 to start at 7:20 (7:20-7:35, 7:35-7:50, etc.), but they would like the 15 minute bars for the markets that open at 7:15 to start at 7:15 (7:15-7:30, 7:30-7:45, etc.). They are able to accomplish this for a single contract by setting the "Session begins (local time)" to any time at or before the product's open time as long as the time difference is evenly divisible by 15 minutes (for instance, for the 7:20 contract, 12:20 AM and 1:20 AM work just as well as 7:20AM). They are also able to simultaneously test all the contracts that open 20 minutes after any hour using this technique. They would like to be able to simultaneously backtest a bunch of contracts at once, with many different open times (7:02, 7:05, 7:09, 7:10, etc.), and have their 15 minute bar open times all open at the correct session open for each product. How can they accomplish this? If they can do this, then they will be able to backtest a 15 minute bar strategy on every contract they have every traded over a period of many years from a single button click! That would be awesome! Thanks in advance! ChiTrader2000
Last edited by ChiTrader2000; 04-08-2009 at 02:39 PM.
|
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
ChiTrader2000,
Sorry I am not understanding what you mean. There is one session definition time used by your strategy. If you want varying start times you will have to build in logic yourself to limit the times processed per bar series.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
NinjaTrader_Josh,
No problem. Let me explain... Some background on my Ninja Trader C# project... I have already done lots of work in C# with limiting the trading times per contract within my code... for instance, we have imported data with lots of 1 minute bar data that is outside of our preferred trading times, so I limit trading on a per contract basis to the preferred trading times defined in our SQL Server 2005 database (I get the Open/Close time in the Initialize() event and I don't allow trading on every OnBarUpdate() event for bars outside our trading times). This part works great so far. What I am unable to achieve in either the C# code or in the Backtest properties dialog box is to force 15 minute bars to start on the open times of each of the contracts in our 1000+ contract backtests, for two reasons:
------------------------------ ------------------------------ So my question is (sorry for the long post!)... Is there something I can do in code or something we can do in the user interface to make sure that, in a big backtest of lots of products with different session open times, that no single 15 minute bar would start before an open time and then close after it (In other words, we don't want any open times to be in the middle of any 15 minute bar. It is OK to have lots of bars before the open, but one bar should close on the session open time and the next bar should open on the session open time)? (Keep in mind that I can already achieve this for a single contract, but want to give my users the ability to backtest all our products from a single button click, instead of 100 button clicks (once per product)). ------------------------------ ------------------------------ Thank you very much for any help in advance! ChiTrader2000
Last edited by ChiTrader2000; 04-08-2009 at 07:14 PM.
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
ChiTrader2000,
Unfortunately this is not supported. The only thing NT handles is one session definition for the primary instrument. All your other instruments just follow the same definition.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
NinjaTrader_Josh and the Ninja Trader Development Team,
Thanks for the quick response. Is there any way that the next version of Ninja Trader can make this possible, either from the user interface or from the C# code? It would be a big selling point for those of us who want to use Ninja Trader to test multiple products at once. With just one button click, the user could test any strategy on every futures contract ever traded in the world, going back as many years as the user has data for, instead of having to constantly worry about which products open at what time. That would be remarkably powerful! Thank you very much for considering my request! ChiTrader2000 |
|
|
|
|
|
#6 | |
|
Senior Member
Join Date: Dec 2006
Location: Seattle, Washington, USA
Posts: 150
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
In your SQL Server 2005 database for each contract, specify the minute on the hour that the contract should be evaluate during OnBarUpdate. Looks like there are 3 scenarios for your 15 minute contracts. Scenario 1: 00, 15, 30, 45 Scenario 2: 05, 20, 35, 50 Scenario 3: 10, 25, 40, 55 For Contracts following Scenario 1: 1a) When the 5-minute bar closes on 15, then you evaluate the bars. 1b) When the 5-minute bar closes on 20, you ignore the bar for this contract. 1c) When the 5-minute bar closes on 25, you ignore the bar for this contract. For Contracts following Scenario 2: 2a) When the 5-minute bar closes on 15, you ignore the bar for this contract. 2b) When the 5-minute bar closes on 20, then you evaluate the bars. 2c) When the 5-minute bar closes on 25, you ignore the bar for this contract. For Contracts following Scenario 3: 3a) When the 5-minute bar closes on 15, you ignore the bar for this contract. 3b) When the 5-minute bar closes on 20, you ignore the bar for this contract. 3c) When the 5-minute bar closes on 25, then you evaluate the bars. You would have to evaluate 5 bars of 5 minutes to get your 15 minute bar in your backtesting. |
|
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
mgbloomfield,
This is a very interesting possibility! Thanks for the great idea! I may end up doing this until hopefully Ninja Trader adds the "15 Minute Bar can start on user-defined Session Open Time for each product in a multi-product backtest" feature that would be so valuable. I am going to think this idea through and maybe program it. I will use 1 minute bars instead of 5 minute bars, as we trade some products with very strange open times. One issue with doing it this way is that the traders won't be able to see the results on the proper 15 minute bars in Ninja Trader, and part of trading system development from their perspective is being able to visually eyeball a bunch of trades produced from a trading idea. Other issues I will need to think through that I can think of are: 1. Sparse data: Sometimes, a 15 minute bar may not have any trades in the last minute or minutes. I would need to close off the 15 minute bar on the last minute with trades (such as the 12th minute, if no trades in last few minutes) to trade in the 15 minute bar. 2. Market breaks (such as in some Asia markets)... this is related to point #1. 3. I would want to use my own calculated bar close time, instead of the end time of the last 1 minute bar, so the users could still use certain time functions as though the imaginary 15 minute bars were really closing at the times that the traders expect them to close at. Can anybody see any other potential issues with this very interesting way of potentially getting around this problem with backtesting multiple products at once? Perhaps this forum thread could serve as a full document on how to achieve this functionality based on mgbloomfield's idea in the previous post. Thanks again for this great idea! ChiTrader2000 |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
Ninja Trader Development Team,
Is there any way that the next version of Ninja Trader can make this possible, either from the user interface or from the C# code? For instance, could you make the "Session begins (local time)" Backtest dialog box property publicly available in a Strategy's "Initialize()" event. If you did, then your users would be able to change the "Session begins (local time)" value in the "Initialize()" event based on what futures product is about to be backtested, which would make the 15 minute bars start at the correct minute after the hour. It would be a big selling point for those of us who want to use Ninja Trader to test multiple products at once. With just one button click, the user could test any strategy on every futures contract ever traded in the world, going back as many years as the user has data for, instead of having to constantly worry about which products open at what time. That would be remarkably powerful! Thank you very much for considering my request! ChiTrader2000
Last edited by ChiTrader2000; 06-04-2009 at 10:48 AM.
|
|
|
|
|
|
#9 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Thank you for the suggestion. We will add it to our list of future considerations, but as you start up a backtest you can already punch in what you want the session times to be so I do not see why there is an issue here.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
NT7 introduces concept of session profiles. Profiels are assigned to instruments and thus, during a backtest, you can set the session to use the profile assigned to the instrument. I am not sure if this will help you or not.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
NinjaTrader_Ray,
I think "session profiles" may be just what I am looking for, but just to clarify:
8:00-8:15, 8:15-8:30, ... But the second product's 15 minute bars should be like: 8:05-8:20, 8:20-8:35, ... Thanks! ChiTrader2000 |
|
|
|
|
|
#12 | |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Quote:
Ray
NinjaTrader Customer Service |
|
|
|
|
|
|
#13 |
|
Senior Member
Join Date: Nov 2008
Posts: 160
Thanks: 0
Thanked 0 times in 0 posts
|
NinjaTrader_Ray,
You made my day! This is really a big deal to our company and the product I am developing, and I really appreciate that the NinjaTrader development team is committed to continually making big improvements to an already very good piece of software. Thanks again, ChiTrader2000 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Market Analyser -Session Start Finish Times | dgregor5 | Market Analyzer | 8 | 03-25-2011 08:37 AM |
| Finding Session Start Times | tradinginzen | General Programming | 3 | 02-23-2009 08:04 AM |
| Session times vs Open & Close Times | Laserdan | Charting | 1 | 10-15-2008 05:46 PM |
| Save each strategy with Session Start and end times. | richa61416 | Suggestions And Feedback | 8 | 05-28-2008 11:56 PM |
| Start & end times for FOREX | bmaltz | Charting | 3 | 05-02-2007 04:50 PM |