Backtest Lab Docs

Entered By

A strategy may open trades from different states as it progresses through its trading logic.

The Entered by setting allows a Trade Exit action to select open trades based on which state originally generated their entry.

This is particularly useful when different states represent different trading setups, and you want to close trades associated with only one of those setups.

Available Options

Any State

Targets open trades regardless of which state originally entered them.

When combined with All trades under the Trades to close setting, this allows the Trade Exit action to target every open trade for the current symbol.

This State

Targets only open trades that were originally entered by the same state in which the Trade Exit action is configured.

This includes trades entered during previous visits to that state, even if the strategy has since moved through other states before returning.

An important distinction: If a state contains both a Trade Entry and a Trade Exit action, selecting This state does not cause the exit action to close the trade requested during the current state entry.

Only trades opened by that state during previous visits are eligible for this exit action.

Selected States

Allows you to choose specific states whose trades should be targeted for exit.

You can select one or more other states from the strategy. Only open trades that originated from those selected states are eligible.

For example, suppose a strategy has two entry states:

  • Breakout Entry, which opens trades following a breakout signal.
  • Reversal Entry, which opens trades following a reversal signal.

A separate Exit Breakout state could use Selected states to target only trades entered by Breakout Entry.

This allows the strategy to close breakout trades without affecting any open trades originating from Reversal Entry.

How the Filters Work Together

The Entered by setting determines where the trades originated, while the Trades to Close setting determines which trade directions are eligible.

Both rules are applied together.

For example, configuring:

  • Trades to close: Only buy trades
  • Entered by: Selected states → Breakout Entry

will target only open buy trades that were originally entered through the Breakout Entry state.

Other open trades remain unaffected by this exit action.