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

# LongestFlatPeriod

## Definition

Returns the longest duration of being flat.

## Property Value

A TimeSpan value that represents the longest duration of being flat.

## Syntax

`\<tradecollection\>.TradesPerformance.LongestFlatPeriod`

## Examples

```csharp
protected override void OnBarUpdate()
{
     // Print out the longest duration of being flat
     Print("Longest flat period: " + SystemPerformance.AllTrades.TradesPerformance.LongestFlatPeriod);
}
```