> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# CS0029

The following **CS0029** 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 error can occur when you try to convert from one **type** to another **type**.

To fix this error, ensure that you are assigning the correct value type.

## Error Description #1

Cannot implicitly convert type '**int**' to '**bool**'

```csharp
// Erroneous Sample Code - 'CurrentBar' is an integer
if (CurrentBar) 
```

```csharp
// Resolution Sample Code - Compares an integer with another integer
if (CurrentBar < 1) 
```

## Error Description #2

Cannot implicitly convert type '**double**' to '**bool**'

```csharp
// Erroneous Sample Code – Close[0] returns A **double** value
if (Close[0]) 
```

```csharp
// Resolution Sample Code – Compares a double with another double
if (Close[0] > Close[1]) 
```

## Error Description #3

Cannot implicitly convert type '**NinjaTrader.NinjaScript.Indicators.SMA**' to '**double**'

```csharp
// Erroneous Sample Code - Incorrect since assigning an indicator to a variable of double type
double myValue = SMA(20);
```

```csharp
// Resolution Sample Code - Correct expression since we are accessing the current bar's value of the SMA indicator
double myValue = SMA(20)[0];
```