![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I want to go long the mini-Dow if the Dow Cash closes down today compared with the previous day. Easy - Closes[1][0] < Closes[1][1]. The mini-Dow is the main instrument in the strategy. If I base the strategy on YM minute bars and wait for after 16:00 EST, the Dow is as of the previous day since Ninja assumes that is the data I want to look at. Obviously, I can't access Closes[1][-1] as the array will not hold that data. Would this work if I based the strategy on daily DJIA and Add(ed) 1-minute YM bars or would it look to tomorrow ? Alternatively, could I cheat and create 1-minute DJIA data which was actually the day close - 20080228 160000;12689.28;12713.99;12463.32;12582.18;3938580 20080229 160000;12579.58;12579.58;12210.3;12266.39;4426730 Thanks, Eric
Last edited by cherriman; 03-05-2008 at 10:07 AM.
Reason: Typos
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Hi Eric,
Be patient with me as I try to understand what you want to do... - You want to go long as the Cash index close of today is less than yesterday - You want to check this condition today after 16:00 EST Is this correct? If yes, what are your session start/end times going to be?
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Ray,
That was quick ! You have it exactly right; if today's Cash close is below yesterday's, I want to go long the mini-Dow. I want to check this as at the Cash close (i.e. just after 4 o'clock). There are obviously certain other conditions ! I'm not sure what you mean by session start/end times so that is probably a big clue ! The position will be held from 16:00EST until it is either stopped out or hits a profit target - this could be any time throughout the night. Sorry to be a thickie - I hope that answers your question albeit indirectly. Thanks, Eric |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Thanks.
Assuming DOW Mini 1 Minute is the primary series and the Daily series is added in Initialize() can you clarify why this would not work: Code:
if (BarsInProgress == 0)
{
if (Closes[1][0] < Closes[1][1] && ToTime(Time[0]) > 160000)
EnterLong();
}
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Ray, I haven't tried your code - mine was within OnBarUpdate() - would that make a difference ?
The condition I had was if ((Closes[1][0] < Closes[1][1]) && (ToTime(Time[0]) > ToTime(16, 00, 0)) && (ToTime(Time[0]) < ToTime(16, 10, 0))). When I do a debug PrintWithTimeStamp, I get 03/01/2008 16:01:00 Pos Flat Dow cl 13043.96 prev 13264.82 13043.96 is the closing price of the 2nd of January, not the 3rd. Thanks, Eric |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
My code is for OnBarUpdate()
Not sure I follow... If you do this: Code:
if (BarsInProgress == 0)
Print(Time[0].ToString() + " " + Closes[1][0])
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Hi Ray,
Tried driving this from both daily and minute perspective - I suspect that Close[0] for daily is updated at midnight ? Here it the output from the debug code running the strategy as of 21st Feb 2008 - 29/02/2008 16:01:00 Pos Flat Dow cl 12582.18 prev 12694.28 This is the actual data 20080227;12683.54;12815.59;12527.64;12694.28;3904700 20080228;12689.28;12713.99;12463.32;12582.18;3938580 20080229;12579.58;12579.58;12210.3;12266.39;4426730 As you can see, on the 29th, Ninja assumes day 0 to be yesterday even after 16:00 EST. I've attached my zipped strategy; I would be grateful if you could help. Thanks, Eric |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Thanks. This is a limitation of NT 6.5 right now. Could you try running the strategy on a daily chart with the secondary series being the 1 minute.
Then in OnBarUpdate() just only process events for the 1 minute. if (BarsInProgress == 1) // Process logic Is the daily bar now pointing to the correct day?
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Ray,
I don't know if I'm doing something wrong but NT is evaluating the YM price in Close[x] using the code you suggested ! I'm running the strategy against ^DJIA. Close[x] points to YM Closes[x][y] points to YM ! Eric |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Right.
Should be: Close[x] Closes[y][x]
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Ray,
That refers to data one bar further back so I'm afraid we're going the wrong way ! By the way, I had assumed that Close[0] would refer to Closes[0][0] - is that incorrect ? Thanks, Eric |
|
|
|
|
|
#12 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
To be clear:
- Apply strategy on daily chart - Strategy has a minute series added via Add() in Initialize() Code:
if (!Historical && BarsInProgress == 1)
Print(Times[0][0].ToString() + " " + Closes[0][0]);
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#13 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
If that should be within OnBarUpdate() it produces no output at all.
|
|
|
|
|
|
#14 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
That would be the case if you were backtesting...
I ran a few tests here and I don't think this is the route we should go down. We have internal limitations (which we will change later this year) in when the close of a daily bar is recognized from an intraday time frame. What you can do is use the GetSessionBar() method which will create a virtual session bar based on your intraday data. http://www.ninjatrader-support.com/H...essionBar.html
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#15 |
|
Member
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
|
Ray,
As far as I can tell from the tests I've run, the close of the daily bar doesn't occur until midnight - 8 hours after I want to test the strategy. Can I cheat by setting up a set of minute data for the Dow cash which is just the close - e.g. 20080228 160000;12689.28;12713.99;12463.32;12582.18;3938580 20080229 160000;12579.58;12579.58;12210.3;12266.39;4426730 Would that work do you think ? Eric |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mixed minute/daily time frames? | monpere | Strategy Development | 12 | 06-08-2011 04:10 PM |
| Pivots Indicator time frames | mazachan | Indicator Development | 3 | 02-24-2008 06:51 PM |
| intraday time frames....is there support available? | leemiles | ATM Strategies (Discretionary Trading) | 1 | 02-04-2008 03:31 PM |
| Multi time frames | bobby1001 | Strategy Development | 1 | 07-23-2007 10:41 AM |
| time frames | knightrider123 | Market Analyzer | 2 | 07-11-2007 01:09 AM |