![]() |
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
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Aug 2009
Posts: 48
Thanks: 3
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Brillo,
Unfortunately we do not support deriving your own class from IDataSeries. You will have to use DataSeries.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Member
Join Date: Aug 2009
Posts: 48
Thanks: 3
Thanked 0 times in 0 posts
|
Quote:
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. |
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Member
Join Date: Aug 2009
Posts: 48
Thanks: 3
Thanked 0 times in 0 posts
|
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. |
|
|
|
|
|
#6 |
|
Senior Member
Join Date: Jul 2009
Location: San Francisco Bay Area
Posts: 216
Thanks: 0
Thanked 4 times in 3 posts
|
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? |
|
|
|
|
|
#7 |
|
NinjaTrader Customer Service
Join Date: May 2008
Location: Denver, CO
Posts: 3,157
Thanks: 0
Thanked 3 times in 3 posts
|
Hello,
I'll have Josh reply on Monday.
Ben
NinjaTrader Customer Service |
|
|
|
|
|
#8 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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
NinjaTrader Customer Service |
|
|
|
|
|
#9 | |
|
Senior Member
Join Date: Jul 2009
Location: San Francisco Bay Area
Posts: 216
Thanks: 0
Thanked 4 times in 3 posts
|
Quote:
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. |
|
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |