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

# Flatten()

## Definition

Flattens the account on an instrument.

## Syntax

`Flatten(ICollection\<instrument\> instruments)`

## Parameters

| Parameter   | Description                                                                 |
| ----------- | --------------------------------------------------------------------------- |
| instruments | A collection of Instruments for orders to be cancelled and positions closed |

## Examples

### Flatten a single instrument

```csharp
Account.Flatten(new [] { Instrument.GetInstrument("ES 12-15") });
```

### Flatten a list of instruments

```csharp
// Please note that your 'Using declarations' section needs to have
//
// using System.Collections.ObjectModel;
//
//added in order for this example to compile correctly

// instantiate a list of instruments
Collection<cbi.instrument> instrumentsToClose = new Collection<instrument>();

// add instruments to the collection
instrumentsToClose.Add(Instrument.GetInstrument("AAPL"));
instrumentsToClose.Add(Instrument.GetInstrument("MSFT"));

// pass the instrument collection to the Flatten() method to be flattened
Account.Flatten(instrumentsToClose);
```