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

# BarsSinceExitExecution()

## Definition

Returns the number of bars that have elapsed since the last exit. When a signal name is provided, the number of bars that have elapsed since that last specific exit will be returned.

## Method Return Value

An **int** value that represents a number of bars. A value of -1 will be returned if a previous exit does not exist.

## Syntax

`BarsSinceExitExecution()`

`BarsSinceExitExecution(string signalName)`

The following method signature should be used when working with [multi-time frame and instrument strategies](/developer/desktop-sdk/guides/educational-resources/multi-time-frame-instruments):

BarsSinceExitExecution(int barsInProgressIndex, string signalName, int exitExecutionsAgo)

When working with a multi-series strategy the BarsSinceExitExecution() will return you the elapsed bars as determined by the first Bars object for the instrument specified in the barsInProgressIndex.

## Parameters

| Parameter           | Description                                                                                                                                                                   |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| signalName          | The signal name of an exit order specified in an order exit method.                                                                                                           |
| barsInProgressIndex | The index of the Bars object the entry order was submitted against. See the [BarsInProgress](/developer/desktop-sdk/references/common/adddataseries/barsinprogress) property. |
| exitExecutionsAgo   | Number of exit executions ago. Pass in 0 for the number of bars since the last exit execution.                                                                                |

Please see [SetStopLoss()](/developer/desktop-sdk/references/strategy/order-methods/managed-approach/setstoploss), [SetProfitTarget()](/developer/unsorted/setprofittarget) or [SetTrailStop()](/developer/desktop-sdk/references/strategy/order-methods/managed-approach/settrailstop) for their corresponding signal name

## Examples

```csharp
protected override void OnBarUpdate()
{ 
   if (CurrentBar < BarsRequiredToTrade) 
       return; 

   // Only enter if at least 10 bars has passed since our last exit or if we have never traded yet
   if ((BarsSinceExitExecution() > 10 || BarsSinceExitExecution() == -1) && CrossAbove(SMA(10), SMA(20), 1))
       EnterLong();
}
```