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 08-24-2009, 10:42 AM   #1
Brillo
Member
 
Join Date: Aug 2009
Posts: 48
Thanks: 3
Thanked 0 times in 0 posts
Default IDataSeries - Can we implement and pass to NT methods/functions?

I’m porting some indicators from TS to NT. One of them uses the TS function:
LinearRegValue. What’s nice about this function is that the data series that’s passed for it to operate on can be something that my indicator calculates ( it can be an expression ).

I see that NT abstracts the concept of a data series in IDataSeries. To achieve the goal of calculating my own data series for a linear regression, I implemented IDataSeries in my own class, which is nested in my main Indicator derived class:

public class MySeries : IDataSeries {…}

Then I moved the calculations for the LinReg series argument into that IDataSeries implementation.

Next the NT indicator is calling

LinReg( new MySeries(),20 );

No compliation errors.
To my surprise, at runtime, NT throws an exception with a message that says the dataseries type is unexpected:
'OnBarUpdate' method for indicator 'TestIndicator' on bar 0: IndicatorBase.set_Input: Unexpected 'DataSeries' type: NinjaTrader.Indicator.ATMSqueeze+MySeries

Questions:
1) Is NT deliberately doing a runtime check on data types and throwing exceptions if the types are not in a list of “sanctioned” types of NT origin? If so then the abstraction of IDataSeries is a bit misleading to the development community.
2) How can I get LinReg to operate on a data series that I calculate myself?
Brillo is offline  
Reply With Quote
Old 08-24-2009, 11:12 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Brillo,

Unfortunately we do not support deriving your own class from IDataSeries. You will have to use DataSeries.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-24-2009, 11:48 AM   #3
Brillo
Member
 
Join Date: Aug 2009
Posts: 48
Thanks: 3
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
Brillo,

Unfortunately we do not support deriving your own class from IDataSeries. You will have to use DataSeries.
Hi Josh,
Thank you for replying promptly. I would appreciate further explanation. I'm new to NT. The reason I'm looking into NT is because of it's C# programming interface. I ran directly into this problem on my 1st indicator authoring attempt.

1) Is there a work around to get LinReg to operate on a series of data that my indicator calculates?
2) What's the rationale behind preventing us from supplying our own IDataSeries implementation? Does it pose a threat to NT or it's partners? I assume there's some threat because: A) Preventing it creates a lack of functionality and breaks the beauty of the object oriented model and it's inherent benefits. B) Preventing it had to be explicitly coded. It's not an oversight.
Brillo is offline  
Reply With Quote
Old 08-24-2009, 11:52 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

1. You can create your own DataSeries. I am not sure what more you would need. If you don't want to use DataSeries, then you can just roll your own methods completely.

2. Unfortunately it is what it is.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-24-2009, 12:39 PM   #5
Brillo
Member
 
Join Date: Aug 2009
Posts: 48
Thanks: 3
Thanked 0 times in 0 posts
Default

Hi Josh,
This DataSeries class looks like it will do what I need. I didn't understand the 1st time you mentioned it. I didn't know it was actually a class. I thought you where referring to native NT types such as close, open, high, etc. collectively as "DataSeries" and that you were saying that I have to use only those! I told you I was new.
Brillo is offline  
Reply With Quote
Old 04-24-2010, 01:00 AM   #6
aviat72
Senior Member
 
Join Date: Jul 2009
Location: San Francisco Bay Area
Posts: 216
Thanks: 0
Thanked 4 times in 3 posts
Default

I also want to pass indicators to custom data-series created during my strategies.

In general the data-series has to be linked to an indicator or a bar. This allows NT to create as many dataseries elements as there are bars in the chart, which permits simple indexing.

However there are situations where the series you want to call the indicator on does not have a one-to-one correspondence with any bar in the indicator/strategy. I want to implement the IDataSeries interface in something which is like a data-series but where the number of bars is not tied to any particular bar series in the strategy.

This need arises because I want some indicators on RTH trading data and some indicators to run on 24/7 data. Currently, I do not think you can specify the session you want to link to when you add a new bar object to a strategy. So I am being forced to create my own custom data-series with RTH only data from the strategy running 24/7. However linking this series to the 24/7 main series running in the strategy defeats the purpose of having bars representing RTH data only.

I can workaround the inability to chose the session I want to tie a new bar object to by maintaining my own DataSeries which is not tied to any bar in the current strategy. Is it possible somehow in NT7?
aviat72 is offline  
Reply With Quote
Old 04-25-2010, 12:12 PM   #7
NinjaTrader_Ben
NinjaTrader Customer Service
 
NinjaTrader_Ben's Avatar
 
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
Default

Hello,

I'll have Josh reply on Monday.
NinjaTrader_Ben is offline  
Reply With Quote
Old 04-26-2010, 08:34 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

aviat72,

If you do not want it tied to bars you will need to use C# arrays instead. Unfortunately I have no resources I can offer you in terms of using arrays, but there are a lot of good resources you can find on google on how to use arrays. You want to use those objects instead of DataSeries objects and your parameter should be looking for arrays instead as well.
NinjaTrader_Josh is offline  
Reply With Quote
Old 04-26-2010, 05:55 PM   #9
aviat72
Senior Member
 
Join Date: Jul 2009
Location: San Francisco Bay Area
Posts: 216
Thanks: 0
Thanked 4 times in 3 posts
Default

Quote:
Originally Posted by NinjaTrader_Josh View Post
aviat72,

If you do not want it tied to bars you will need to use C# arrays instead. Unfortunately I have no resources I can offer you in terms of using arrays, but there are a lot of good resources you can find on google on how to use arrays. You want to use those objects instead of DataSeries objects and your parameter should be looking for arrays instead as well.
Josh

I was hoping not to have to rewrite the indicators to accept arrays.

In my situation I want a bar series from a different session in the same strategy. I can manually create the bar-series by filtering the incoming bars but do not have a class which implements the IDataSeries interface to pass it to the indicators.
aviat72 is offline  
Reply With Quote
Old 04-27-2010, 08:48 AM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Unfortunately IDataSeries objects would have to be tied to a bar series and that would mean the same number of indexes as the underlying bar series. If you want to just "ignore" some bars you can try not setting any values on the bars you don't want.
NinjaTrader_Josh 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
NT functions list Jbarn General Programming 11 10-29-2011 06:40 AM
implement a function on NT kuroro13 Indicator Development 8 08-06-2008 05:31 PM
NT DLL functions clearpicks Automated Trading 4 05-28-2008 07:59 AM
Available Methods/Properties in NT devonkyle General Programming 1 04-14-2008 06:50 PM
New Pass in MB now I can't login to NT eudamonia Connecting 3 03-07-2007 06:18 AM


All times are GMT -6. The time now is 06:37 PM.