NinjaTrader Support Forum  

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 07-26-2007, 01:13 PM   #1
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default IDataSeries problem

I've tried to code an indicator that gives some warning with various actions of the CCI. It doesn't compile and I'm pretty sure I need to somehow use IDataSeries, but that is very confusing to me. Can you take a look?

Richard
Attached Files
File Type: cs vWCCICross.cs (7.7 KB, 4 views)
Richard Von is offline  
Reply With Quote
Old 07-26-2007, 01:34 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

I noticed another mistake in my prior post so I deleted it. Here is a new one.
There are several issues I see.

1) Your usage of CCI is incorrect.

Should be CCI(Length) instead of CCI(Length, 0). This will use the Close price, if you wanted the High price use CCI(High, Length)

2)

You have:

double x = CCI(Length, 0);

should be:

double x = CCI(Length)[0];

You are assigning the indicator itself to x instead of the value of the indicator at a specific bar.
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-26-2007, 01:58 PM   #3
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default Error Message

Thanks for helping.

I've made that change but when I try to compile I get the message: "Your indicator has one or more recursive properties that could cause NinjaTrader to crash: Length. Do you want to edit these properties?"

I can't see what would be wrong with Length, but don't know what recursive is.
Richard Von is offline  
Reply With Quote
Old 07-26-2007, 02:02 PM   #4
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default

I can't tell with the error message about recursive properties if these other errors are still there, but they say: "The best overloaded method match for 'NinjaTrader.Data.Indicator.Indicator.CCI(NinjaTra der.Data.IDataSeries,int)' has some invalid arguments. Argument '1': cannot convert of 'int' to 'NinjaTrader.Data.IDataSeries'
Richard Von is offline  
Reply With Quote
Old 07-26-2007, 02:12 PM   #5
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Recursive means that you have an infinite loop in your code.

Check under properties, you will see something like:

public int Length

inside you will see Length = value;

change to lower case

length = value;

also change the "getter" to show "return length" instead of "return Length"
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-26-2007, 02:29 PM   #6
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default Partial fix

Your 4:12 post seems to have taken care of the recursive message. Still have issue of IDataSeries.

I appreciate your help.
Richard Von is offline  
Reply With Quote
Old 07-26-2007, 02:36 PM   #7
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default Eureka!

Found problem in my use of x in CrossAbove, CrossBelow. Now OK -- at least compiles. Now I have to see if it works! Thanks.
Richard Von is offline  
Reply With Quote
Old 07-26-2007, 02:37 PM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Double check all methods (indicators/functions) that you use and ensure you are passing in the correct parameter types.

The problem is that you are passing in int and double values into the CrossAbove() and CrossBelow() methods. Check the DOC on these methods to see the correct syntax. They can accept a double value but it also needs at least one value which is of type IDataSeries. You can check the DOC on the DataSeries Class as well to gain an understanding of how that works.
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-26-2007, 03:41 PM   #9
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default

I'll let you know when I am able to test this to see if it works.

I have studied the documentation on DataSeries but just don't understand it.
Richard Von is offline  
Reply With Quote
Old 07-27-2007, 11:16 AM   #10
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default Compiles but doesn't work

I have gotten the code attached to compile with no errors and it appears to have the right logic to me, but when I apply it to a chart nothing happens.

This code is to do the following:

Determine if the CCI one bar back is above an Upper bound.
If so, as the current bar approaches within a Warning amount, sound an alert and color the price bars.
As it then crosses the Upper bound, sound another alert and color the price bars another color.

Same for when CCI is below the Lower bound.

What am I missing please?
Attached Files
File Type: cs vWCCICross.cs (7.9 KB, 4 views)
Richard Von is offline  
Reply With Quote
Old 07-27-2007, 01:49 PM   #11
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Hi Richard,

Unfortunately we are unable to provide debugging support however, we do help out time permitting as you have already experienced.

Any time an indicator does not work, there usually will be an error in the log tab of the control center window which might provide you a clue as to what the issue might be.

A common error is an index out of range error which usually is a result of trying to access a bar that does not yet exist. I would check your code for that.

If you access something like Close[2] for the close of 2 bars ago, you want to make sure you have something like

if (CurrentBar < 2)
return;

Since this will check to make sure there are enough bars to get a value from 2 bars ago.
NinjaTrader_Ray is offline  
Reply With Quote
Old 07-30-2007, 06:23 AM   #12
Richard Von
Member
 
Join Date: Jul 2007
Posts: 93
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks, that helped. Working on logic now.
Richard Von 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


All times are GMT -6. The time now is 10:09 PM.