![]() |
|
|||||||
| Strategy Analyzer Support for automated system backtesting and optimization using the NinjaTrader Strategy Analyzer. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Aug 2008
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
I'm creating a strategy that needs to verify certain conditions exist in both the daily time frame and weekly time frame. I have historical daily data from Yahoo loaded.
Is it possible to create an array of weekly bar data from daily bar data? Similar to what is explained on this page but instead of creating a 1 minute and a 3 minute array of bar data from 1 minute data, I need to create a daily and weekly array from daily data? Obviously the daily array is default, but how do I get the weekly from the daily data? Thanks. |
|
|
|
|
|
#2 |
|
Junior Member
Join Date: Aug 2008
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
Do I put Add(PeriodType.Day); and Add(PeriodType.Week); in the Initialize() function area, and then access the daily array using BarsArray[1] and access the weekly array using BarsArray[2]?
Or do I enter only Add(PeriodType.Week); in the Initialize() function area, and access the daily data using BarsArray[0] and access the weekly array using BarsArray[1]? Or is that completely wrong?
Last edited by pmn100; 08-25-2008 at 12:57 PM.
|
|
|
|
|
|
#3 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
>> Or do I enter only Add(PeriodType.Week); in the Initialize() function area, and access the daily data using BarsArray[0] and access the weekly array using BarsArray[1]?
correct
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Aug 2008
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
Thanks Dierk
|
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Aug 2008
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
This isn't working for me.
I've put Add(PeriodType.Week, 1); into the initialize() function area. I've then used the following code example to try and access this bar array: if (SMA(BarsArray[0], 5)[0] > SMA(BarsArray[0], 50)[0] && SMA(BarsArray[1], 5)[0] > SMA(BarsArray[1], 50)[0])In English, if the 5 period SMA is above the 50 period SMA on the daily bars and the 5 period SMA is above the 50 period SMA on the weekly bars, enter short. But this is giving me no orders/no results. I've checked the charts and orders should have been activated.
Last edited by pmn100; 08-26-2008 at 10:27 AM.
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Aug 2008
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
If I delete the Add(PeriodType.Week, 1); and use just the following code, I do get results and orders are activated:
if(SMA(BarsArray[0], 5)[0] > SMA(BarsArray[0], 50)[0]) So why isn't it recognising the weekly bar array? I've back tested using the DOW 30 from 2005 onwards, with daily bar data from Yahoo Finance. Daily, weekly, monthly charts display no problem. |
|
|
|
|
|
#7 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
I suggest adding some Print() statements to see what the values of the SMA on the weekly bars are and etc...
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Aug 2008
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
I've simplified the code now to this:
if (SMA(5)[0] > 1 && SMA(BarsArray[1], 5)[0] > 1)And still no orders. That is simply if the 5 bar SMA is above 1 on both daily and weekly charts. Which they all are. This is what I've got. What am I not doing right? protectedoverridevoid Initialize() |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Aug 2008
Posts: 27
Thanks: 0
Thanked 0 times in 0 posts
|
I think I've narrowed it down to BarsSinceEntry() That function doesn't seem to want to work in multi time frames.
I'm using daily and weekly time frames. I want the BarsSinceEntry() to apply to the daily time frame. Is this possible using BarsInProgress or something? |
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
BarsSinceEntry() needs to be used with the multi-time frame syntax. Please see the Help Guide for more information. We are aware of some bugs with it right now which will be addressed in the next update.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multi-Time Frame & Bar Data Reference | michaelbb | Strategy Development | 3 | 06-11-2008 07:08 AM |
| Can't veiw my daily, weekly and monthly charts....HELP... | amaruenterprise | Charting | 6 | 05-28-2008 11:22 PM |
| How do I create memory efficient Time Series Data | LlewS | General Programming | 2 | 01-12-2008 03:10 PM |
| Displaying daily and weekly data from yahoo? | mazachan | Historical NinjaTrader 6.5 Beta Threads | 2 | 11-30-2007 12:51 PM |
| Daily and Weekly Pivots don't work! | nightowl | Charting | 4 | 03-07-2007 01:00 AM |