PDA

View Full Version : double to int ?


zoltran
03-13-2007, 05:23 PM
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

NinjaTrader_Dierk
03-13-2007, 10:10 PM
a) try double myroc = ROC((int) ma,5);
b) something like
myDoubleValue = NameOfYourIndicator(whatever-parameters-your-indicator-has)[0];

zoltran
03-14-2007, 01:49 AM
Dierk Droth wrote: a) try double myroc = ROC((int) ma,5);

Hi
That gives 'Cannot implicitly convert type 'Ninjatrade.indicator.ROC' to 'double'

NinjaTrader_Dierk
03-14-2007, 01:51 AM
Please try
double myroc = ROC((int) ma,5)[0];