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 03-13-2007, 05:23 PM   #1
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Hello .. I'm exerimenting here.
I would like to plot a ROC (Rate of change) of a MA, in this case a VMA.
But I'm geting confounded with data types.
Not that proficient with C#
Thanks .. here's the sample code.

protected override void OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
double ma = VMA(Close,9,9)[0];
double myroc = ROC(ma,5) ;
RocMA.Set(myroc);
Errors
The best overloaded method match for 'NinjaTrader.Indicator.Indicator.ROC(int Argument '1': cannot convert from 'double' to 'int'

Also .. once this indicator is completed.. what would the code look like to refer to it from another indicator/strategy?

Thanks
zoltran is offline  
Reply With Quote
Old 03-13-2007, 10:10 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
Post imported post

a) try double myroc = ROC((int) ma,5);
b) something like
Code:
myDoubleValue = NameOfYourIndicator(whatever-parameters-your-indicator-has)[0];
NinjaTrader_Dierk is offline  
Reply With Quote
Old 03-14-2007, 01:49 AM   #3
zoltran
Senior Member
 
Join Date: Nov 2005
Location: , Ontario, Canada
Posts: 400
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

Dierk Droth wrote:
Quote:
a) try double myroc = ROC((int) ma,5);
Hi
That gives 'Cannot implicitly convert type 'Ninjatrade.indicator.ROC' to 'double'
zoltran is offline  
Reply With Quote
Old 03-14-2007, 01:51 AM   #4
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
Post imported post

Please try
Code:
double myroc = ROC((int) ma,5)[0];
NinjaTrader_Dierk 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 09:35 AM.