> 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.

# n Bars Up

## Description

Evaluates for n number of consecutive higher closes. Returns a value of 1 when the condition is true or 0 when false.

## Syntax

`NBarsUp(int barCount, bool barUp, bool higherHigh, bool higherLow)`

`NBarsUp(ISeries\<double\> input, int barCount, bool barUp, bool higherHigh, bool higherLow)`

**Returns default value**

`NBarsUp(int barCount, bool barUp, bool higherHigh, bool higherLow)[int barsAgo]`

`NBarsUp(ISeries\<double\> input, int barCount, bool barUp, bool higherHigh, bool higherLow)[int barsAgo]`

## Return Value

**double;** Accessing this method via an index value `[int barsAgo]` returns the indicator value of the referenced bar.

## Parameters

| Parameter      | Description                                                                                     |
| -------------- | ----------------------------------------------------------------------------------------------- |
| **input**      | Indicator source data ([Series\<T>](/developer/desktop-sdk/references/common/iseriest/seriest)) |
| **barCount**   | The number of required consecutive higher closes                                                |
| **barUp**      | Each bar's close must be higher than the open; true or false                                    |
| **higherHigh** | Consecutive higher highs required; true or false                                                |
| **higherLow**  | Consecutive higher lows required; true or false                                                 |

## Examples

```csharp
// OnBarUpdate method
protected override void OnBarUpdate()
{
   // Evaluates if we have 3 consecutive higher closes
   double value = NBarsUp(3, true, true, true)[0];
 
   if (value == 1)
       Print("We have three consecutive higher closes");
}
```

## Source Code

You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.