Richard
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
IDataSeries problem
Collapse
X
-
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?
RichardTags: None
-
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.RayNinjaTrader Customer Service
-
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.
Comment
-
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'
Comment
-
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"RayNinjaTrader Customer Service
Comment
-
Partial fix
Your 4:12 post seems to have taken care of the recursive message. Still have issue of IDataSeries.
I appreciate your help.
Comment
-
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.
Comment
-
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.RayNinjaTrader Customer Service
Comment
-
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.
Comment
-
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
Comment
-
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.RayNinjaTrader Customer Service
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bmartz, 03-12-2024, 06:12 AM
|
5 responses
32 views
0 likes
|
Last Post Today, 08:34 AM | ||
Started by Aviram Y, Today, 05:29 AM
|
4 responses
13 views
0 likes
|
Last Post
by Aviram Y
Today, 07:57 AM
|
||
Started by algospoke, 04-17-2024, 06:40 PM
|
3 responses
28 views
0 likes
|
Last Post Today, 07:41 AM | ||
Is it possible to have a drawing, such as a line, cycle through different colors?
by gentlebenthebear
Started by gentlebenthebear, Today, 01:30 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:30 AM | ||
Started by cls71, Today, 04:45 AM
|
1 response
8 views
0 likes
|
Last Post Today, 07:25 AM |
Comment