Skip to main content
The Position Executor places an entry order and, once filled, manages the position using the Triple Barrier Method—automatically closing at take profit, stop loss, trailing stop activation, or time limit.

Overview

How It Works

  1. Entry: Places order at entry_price (or market if not specified)
  2. Monitor: Once filled, continuously monitors price against barriers
  3. Exit: First barrier hit triggers position close
  4. Report: Reports P&L and terminates

Configuration

Triple Barrier Config

The TripleBarrierConfig defines all exit conditions:

Take Profit

Closes position when price moves in your favor by the specified percentage.
For a long position entered at 100,takeprofittriggersat100, take profit triggers at 102.

Stop Loss

Closes position when price moves against you by the specified percentage.
For a long position entered at 100,stoplosstriggersat100, stop loss triggers at 99.

Time Limit

Closes position after a maximum duration, regardless of P&L.

Trailing Stop

A dynamic stop loss that follows the price as it moves in your favor.
How it works:
  1. Position enters at $100
  2. Price rises to $101 (1% profit) → trailing stop activates
  3. Stop is placed at $100.50 (0.5% below current price)
  4. Price rises to 103stopmovesto103 → stop moves to 102.49
  5. Price drops to $102.49 → trailing stop triggers, position closes
The trailing stop locks in gains while letting winners run.

Parameters

Order Types

You can configure which order type to use for each action:
Use LIMIT for entries and take profits to get better fills. Use MARKET for stop losses to ensure execution.

Example: Scalp Trade

Example: Swing Trade with Trailing Stop

Close Types

When the executor terminates, it reports which barrier was hit:

Position Handover

If keep_position=true (set via early stop):
  • Position remains open in the account
  • Added to agent’s Position Hold for later management
If keep_position=false (default for barrier exits):
  • Position fully closed
  • Realized P&L calculated and reported