NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support > Historical Version 7 Beta Threads > Version 7 Beta General Questions & Bug Reports

Version 7 Beta General Questions & Bug Reports Ask questions here and post bug reports.

 
 
Thread Tools Display Modes
Old 06-30-2010, 02:44 PM   #1
dpennypacker
Junior Member
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default Multi TimeFrames -- 2nd Secondary

I'm getting an error when trying to access secondary bars when using multi-timeframes. The primary chart is a 15-minute chart and I'm adding a 5-minute and 125-Tick chart in the Initialize function.

In the OnBarUpdate function, I'm able to access data in the 5-minute chart, but unable to get data for the 125-tick chart.

My understanding is the the BarsArray object is zero based with the first item being the primary bars.

Below is the code snippet I'm using. I'm getting the error on the third Print statement.

So my main question is why the second instrument(125-Tick), not being populated correctly. When I check the Length property of the BarsArrary object it's reporting 3.


In my Initialize function I have the following

See Attachment
Attached Files
File Type: txt CodeSnippet.txt (1.5 KB, 4 views)
dpennypacker is offline  
Old 06-30-2010, 02:52 PM   #2
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
Default

dpennypacker, I don't think that is the issue. In your code snippet, I see the error is this:
Code:
Error on calling 'OnBarUpdate' method for indicator 'PriceActionPlus3X' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
That error is typically caused by trying to access data that doesn't actually exist. For example, on the very first bar the indicator sees, if you try to access High[1], the error will happen because there is only one bar to deal with.

Would you mind posting the complete code so I can see what else is going on in the indicator?
NinjaTrader_Austin is offline  
Old 06-30-2010, 03:20 PM   #3
dpennypacker
Junior Member
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default re: Multi TimeFrames -- 2nd Secondary

NinjaScript is attached.
dpennypacker is offline  
Old 06-30-2010, 03:28 PM   #4
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
Default

dpennypacker, unfortunately nothing was attached to the previous post. To attach a file, click the little paper clip above the response box, select the file you wish to attach, click upload, and then submit the reply.

Oh and I forgot to say this in my first post, but welcome to the forums!
NinjaTrader_Austin is offline  
Old 06-30-2010, 03:33 PM   #5
dpennypacker
Junior Member
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default re: Multi TimeFrames -- 2nd Secondary

2nd attempt at the attachment.
Attached Files
File Type: cs PriceActionPlus3X.cs (16.1 KB, 3 views)
dpennypacker is offline  
Old 06-30-2010, 03:43 PM   #6
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
Default

Hi there, I ran your script with some additional Print() statements scattered throughout your Print() statements and determined the issue lies within these codes:
Code:
Print(string.Format("k12: {0}, k22: {1}, k32: {2}", k12.K[0],k22.K[0],k32.K[0]));
Print(string.Format("k13: {0}, k23: {1}, k33: {2}", k13.K[0],k23.K[0],k33.K[0]));
After adding a simple bar check, the script runs fine. Please add this snippet after your BarsInProgress check:
Code:
if (CurrentBar < 5)
    return;
Two bars wasn't enough and five works so I just left it at that.

Please take a look at the screenshot for what I just said in picture format.
Attached Images
File Type: png obu.PNG (7.9 KB, 6 views)
NinjaTrader_Austin is offline  
Old 06-30-2010, 04:29 PM   #7
dpennypacker
Junior Member
 
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
Default

I guess I'll have to read up a little more on the CurrentBar.

Thanks for looking at this.
dpennypacker is offline  
Old 06-30-2010, 04:38 PM   #8
NinjaTrader_Austin
NinjaTrader Customer Service
 
NinjaTrader_Austin's Avatar
 
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
Default

This is the tip we have for making sure you have enough bars in the data series you are accessing, which is basically what you're dealing with here.
NinjaTrader_Austin is offline  
 

Tags
add, multiple timeframes

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
SetStopLoss() in multi timeframes DarthTraderson Strategy Development 11 03-01-2013 03:39 AM
No Luck with 2nd data series lpart Version 7 Beta General Questions & Bug Reports 4 05-28-2010 03:25 PM
RSI (multi timeframes) returned values are different between Ninja 6.5 and 7 Jean-Marc-Molina Version 7 Beta General Questions & Bug Reports 6 11-16-2009 08:51 AM
How to strategy test against multi timeframes ? wcredle Strategy Analyzer 1 03-13-2009 03:37 PM
Secondary instrument access? ct Strategy Development 2 05-13-2007 01:49 AM


All times are GMT -6. The time now is 05:32 PM.