![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
|
Hi everyone,
Just installed NJ and loving it. I tried to build a simple custom indicator, based on the difference of two RSI (on different length), but I cannot build it using the double function: double RS1 = RSI... double RS2 = RSI... double diff = RS1 - RS2 I get "Cannot implicitly convert type Ninjatrader.Indicator.RSI to double CS0029. I understand I cannot use double to subtract two indicators, but how am I supposed to do? Thank you everyone for help |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Unfortunately this is not supported. You would need to implement a custom indicator which subtracts these values data point by data point and stuffs the result in its own plot/data series.
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#3 | |
|
Senior Member
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
|
Quote:
Could you explain (with an example or with a similar indicator) how to do that? Otherwise I don't think I will manage to move forward...
|
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
I suggest ripping through our indicator code samples and the references and tips here:
http://www.ninjatrader-support.com/v...splay.php?f=30 http://www.ninjatrader-support.com/v...splay.php?f=31
Dierk
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
|
Following the tutorials:
1) I introduced the variables: #region Variables private DataTimeSeries RSI1; DataTimeSeries RSI2; #endregion 2) I declared the variables: RSI1.Set(RSI(...)); RSI2.Set(RSI(...)); RSI1 = new DateTimeSeries(this); RSI2 = new DateTimeSeries(this); double diff = RSI1 - RSI2; Yet, it doesn't work! Who can help me with an example? Thank you everyone |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Please import the attached via Files > Utilities and review the source code.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
|
Thank you, Ray, but it doesn't work yet!
#region Variables private DataSeries mySeries1; DataSeries mySeries2; #endregion mySeries1 = new DataSeries(this); mySeries2 = new DataSeries(this); protected override void OnBarUpdate() { double myValue1 = RSI(Close, x, y); double myValue2 = RSI(Close, x, z); mySeries1.Set(myValue1); mySeries2.Set(myValue2); double Diff = myValue1 - myValue2; Plot0.Set(Diff); } Please anyone can tell me what's wrong? I'm spending sooooooo much time on it, I'm getting desperate!
|
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Try this:
protected override void OnBarUpdate() { double myValue1 = RSI(Close, x, y)[0]; double myValue2 = RSI(Close, x, z)[0]; mySeries1.Set(myValue1); mySeries2.Set(myValue2); double Diff = myValue1 - myValue2; Plot0.Set(Diff); } however, what you are doing is redundant, I would do this and skip using any DataSeries object: protected override void OnBarUpdate() { Plot0.Set(RSI(Close, x, y)[0] - RSI(Close, x, z)[0]); }
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Apr 2008
Posts: 310
Thanks: 0
Thanked 0 times in 0 posts
|
I finally generated the indicator (using the latter expression you suggested), but I get a 0 flat line as indicator. Why?
Thank you |
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Since the value of the calculation is likely zero. You will need to debug it.
Here is some guidance - http://www.ninjatrader-support.com/v...ead.php?t=3418
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| we need indicators !!! | Elmi | Indicator Development | 77 | 07-25-2012 10:15 AM |
| new indicators | JAY526 | Charting | 28 | 12-19-2011 03:19 PM |
| Charting indicators using other indicators as the input | Elliott Wave | Charting | 3 | 04-04-2008 03:54 PM |
| Subtract an indicator | snake | Strategy Development | 1 | 06-06-2007 02:22 PM |
| TTM Indicators | Freddie | Indicator Development | 1 | 03-11-2007 06:28 AM |