NinjaTrader Support Forum  

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 03-05-2008, 10:03 AM   #1
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Question Mixed time frames

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
cherriman is offline  
Reply With Quote
Old 03-05-2008, 10:23 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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?
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-05-2008, 10:37 AM   #3
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Default

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
cherriman is offline  
Reply With Quote
Old 03-05-2008, 10:58 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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();
}
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-05-2008, 11:10 AM   #5
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Default

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
cherriman is offline  
Reply With Quote
Old 03-05-2008, 11:18 AM   #6
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

My code is for OnBarUpdate()

Not sure I follow...

If you do this:

Code:
if (BarsInProgress == 0)
    Print(Time[0].ToString() + " " + Closes[1][0])
I would expect that you get the close price of daily bars of the time stamp you printed out. Is this not the case?
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-06-2008, 07:00 AM   #7
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Default

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
Attached Files
File Type: zip on2.zip (1.0 KB, 4 views)
cherriman is offline  
Reply With Quote
Old 03-06-2008, 07:49 AM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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?
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-06-2008, 09:40 AM   #9
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Question

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
cherriman is offline  
Reply With Quote
Old 03-06-2008, 09:54 AM   #10
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Right.

Should be:

Close[x]
Closes[y][x]
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-06-2008, 10:33 AM   #11
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Default

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
cherriman is offline  
Reply With Quote
Old 03-06-2008, 10:52 AM   #12
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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]);
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-06-2008, 12:08 PM   #13
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Default

If that should be within OnBarUpdate() it produces no output at all.
cherriman is offline  
Reply With Quote
Old 03-06-2008, 12:47 PM   #14
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

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
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-07-2008, 10:21 AM   #15
cherriman
Member
 
Join Date: Mar 2008
Location: Teddington
Posts: 45
Thanks: 0
Thanked 0 times in 0 posts
Default

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
cherriman 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
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


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