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-03-2007, 05:55 PM   #1
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default Operator Error Message

I am writing an indicator that is a variation of the CCI. The CCI normally uses typical which is (high + low + close) / 3. I want to redefine typical to be
myTypical = (Max(High, 3)+Min(Low, 3)+Close) / 3

Simple enough but I don't know how to work around the strongly typed C#.

These are the code snippets where I attempt to do this.
Variable Declaration...
private DataSeries myTypical;

protected void RedefineTypical()
{
myTypical.Set((Math.Max(High[0], 3)+Math.Min(Low[0], 3)+Close[0]) / 3);
}
Ok I know you know what's coming next. I get a compile error stating Operator '+' cannot be applied to operands of type 'NinjaTrader.Data.lDataSeries' and 'NinjaTrader.Data.lDataSeries'

Also I get an error "the best overloaded method match for system.math.mas(sbyte,sbyte) has some invalid arguments. argument '1' cannot convert from ninjatrader.dat.idataseries to sbyte.
Thank you for your help.
Mike
Last edited by Mike Winfrey; 08-03-2007 at 06:00 PM.
Mike Winfrey is offline  
Reply With Quote
Old 08-03-2007, 11:35 PM   #2
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Default

Code line below has no error. Just click on the error message, it will bring you to the erroneous code line.
NinjaTrader_Dierk is offline  
Reply With Quote
Old 08-04-2007, 05:53 AM   #3
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default Operator Error Message

Thank you for the timely reply, especially at midnight. Holy cow...don't you sleep? Incredible. Anyway, I know about double clicking on the error message which is how I found out where the error is and the error is just as I described. However, I notice that I sent you the wrong code. That error was accurate for that code but obviously doesn't apply now. Don't know what I was thinking but anyway can we please start over.

Here's the real code that I want to work...a screen shot of this code and the error are attached. The screen shot also shows how I want to use this method and is at the bottom of the code.

#region Variables
private int period = 14;
private DataSeries myTypical;
#endregion

protected void RedefineTypical()
{
myTypical.Set((Math.Max(High, 3)+Math.Min(Low, 3)+Close) / 3);
}

protected override void OnBarUpdate()
{
if (CurrentBar == 0)
Value.Set(0);
else
{
double mean = 0;
for (int idx = Math.Min(CurrentBar, Period - 1); idx >= 0; idx--)
mean += Math.Abs(myTypical[idx] - SMA(myTypical, Period)[0]);
Value.Set((myTypical[0] - SMA(myTypical, Period)[0]) / (mean == 0 ? 1 : (0.015 * (mean / Math.Min(Period, CurrentBar + 1)))));
}
}
Attached Images
File Type: jpg Code-1.JPG (88.9 KB, 12 views)
Mike Winfrey is offline  
Reply With Quote
Old 08-04-2007, 09:39 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Here is one problem, you as passing in a DataSeries object of high prices (High) to Math.Max() instead of a double value.

Math.Max(High[0], 3)

instead of

Math.Max(High, 3)
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-04-2007, 02:24 PM   #5
Mike Winfrey
Senior Member
 
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
Default

Thank you...i made the change as you suggested which looks like this.

myTypical.Set((Math.Max(High[0], 3)+Math.Min(Low[0], 3)+Close[0]) / 3);

and now it successfully compiles. I have other issues now but i'll work on them a bit before I bother anyone with it.

Thanks,
Mike
Mike Winfrey 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
Unexpected error -104 message muthaf Automated Trading 8 05-08-2008 01:20 AM
Stumped by error message scjohn Strategy Development 3 06-17-2007 07:46 PM
Error Message 10001 nelson Miscellaneous Support 5 06-02-2007 07:34 PM
Error Message ardenb Installation and Licensing 4 04-11-2007 05:09 PM
What does this error message mean? funk101 Strategy Development 1 04-05-2007 02:42 AM


All times are GMT -6. The time now is 04:42 AM.