![]() |
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 |
|
Senior Member
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
|
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.
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Code line below has no error. Just click on the error message, it will bring you to the erroneous code line.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
|
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))))); } } |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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)
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Aug 2007
Posts: 310
Thanks: 3
Thanked 2 times in 2 posts
|
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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |