NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-30-2012, 05:38 AM   #1
JoshDance
Senior Member
 
Join Date: Dec 2010
Posts: 406
Thanks: 22
Thanked 23 times in 12 posts
Default DataSeries on a secondary data series

I am not sure that I am correctly initializing my DataSeries which I want to sync with my secondary data series. In Initialize() I'm doing:

Code:
Add(PeriodType.Minute,1);
And in OnBarUpdate() I'm doing this just to see if I'm on the right track (and I'm not):

Code:
if (cumVol == null && BarsInProgress == 1)
	cumVol = new DataSeries(this, MaximumBarsLookBack.Infinite);
		
if (cumVol != null && BarsInProgress == 1 && cumVol.ContainsValue(0))
	Print("dataseries for bar " + CurrentBar + " is " + cumVol[0]);
However I get the error:

Code:
Error on calling 'OnBarUpdate' method for indicator 'RelativeVolume' 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.
I looked at the thread:
http://www.ninjatrader.com/support/f...ead.php?t=3572

But it showed the example of initializing the secondary DataSeries with an indicator, and I am wanting to manually fill in the values. I suspect my initialization is incorrect, but I don't have any other reference to go by.
JoshDance is offline  
Reply With Quote
Old 05-30-2012, 05:51 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
Default

JoshDance, please go alongside the example provided for the sync - it would need to be an indicator as it implements an IDataSeries interface so you can provide the BarsArray to sync to.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-30-2012, 05:52 AM   #3
JoshDance
Senior Member
 
Join Date: Dec 2010
Posts: 406
Thanks: 22
Thanked 23 times in 12 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
JoshDance, please go alongside the example provided for the sync - it would need to be an indicator as it implements an IDataSeries interface so you can provide the BarsArray to sync to.
And then do I manually go through the DataSeries when the indicator loads and in each OnBarUpdate() I can set my own values?
JoshDance is offline  
Reply With Quote
Old 05-30-2012, 05:53 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,414
Thanks: 252
Thanked 978 times in 961 posts
Default

Correct, you can set your own values then in the correct BIP. What we discussed is just the initial sync.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-30-2012, 11:29 AM   #5
JoshDance
Senior Member
 
Join Date: Dec 2010
Posts: 406
Thanks: 22
Thanked 23 times in 12 posts
Default

Quote:
Originally Posted by NinjaTrader_Bertrand View Post
Correct, you can set your own values then in the correct BIP. What we discussed is just the initial sync.
Thanks Bertrand, got it working and indicator finished. Thanks for your help!
JoshDance 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
Secondary Series and Data, Int, Bool Series TAJTrades General Programming 1 03-24-2012 08:13 AM
Secondary data series in Indicator mokodo General Programming 2 03-22-2012 04:35 AM
Syncing custom DataSeries to secondary series buylosellhi General Programming 4 08-11-2011 09:30 PM
Referencing secondary data series for a strategy daven Strategy Development 4 06-26-2011 08:46 PM
Weekend data not triggering on secondary time series gert74 Strategy Development 12 08-28-2007 08:12 PM


All times are GMT -6. The time now is 03:39 PM.