![]() |
|
|||||||
| Version 7 Beta General Questions & Bug Reports Ask questions here and post bug reports. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
|
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. Would you mind posting the complete code so I can see what else is going on in the indicator?
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
NinjaScript is attached.
|
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
|
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!
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
2nd attempt at the attachment.
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
|
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]));
Code:
if (CurrentBar < 5)
return;
Please take a look at the screenshot for what I just said in picture format.
Austin
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Mar 2009
Posts: 10
Thanks: 0
Thanked 0 times in 0 posts
|
I guess I'll have to read up a little more on the CurrentBar.
Thanks for looking at this. |
|
|
|
|
|
#8 |
|
NinjaTrader Customer Service
Join Date: Jun 2009
Location: Denver, CO
Posts: 3,149
Thanks: 10
Thanked 90 times in 82 posts
|
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.
Austin
NinjaTrader Customer Service |
|
|
|
| Tags |
| add, multiple timeframes |
| Thread Tools | |
| Display Modes | |
|
|
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 |