NinjaScript > Editor > Compile Error Codes >

CS0021

Print this Topic Previous pageReturn to chapter overviewNext page

The following CS0021 error code information is provided within the context of NinjaScript. The examples provided are only a subset of potential problems that this error code may reflect.  In any case, the examples below provide a reference of coding flaw possibilities.

 

Error Code Explanation

This is a common error when calling indicators methods. It occurs when an indicator is called without its required parameter arguments before accessing an indexed value.

 

To fix this error you will need to first pass to the indicator method all the necessary parameter arguments. You can do this with '()' after the indicator name. Please note that you will still need to pass an empty parameter argument list even if your indicator requires no arguments.

 

Error Description #1
Cannot apply indexing with [] to an expression of type 'method group'

 

Example #1

// Erroneous Sample Code - SMA is an indicator and requires parameter arguments

double value = SMA[0];

 

// Resolution Sample Code - SMA() properly called

double value = SMA(14)[0];

 

Example #2

// Erroneous Sample Code - EMA is an indicator and requires parameter arguments

double maDelta = EMA[0] - EMA[1];

 

// Resolution Sample Code - SMA() properly called with an overload method (one of several variations)

double maDelta = EMA(High, 14)[0] - EMA(High, 14)[1];