How to automate exit plans and take profits with an AI agent
A step-by-step guide to configuring automated exit plans and take-profit rules so an AI agent closes positions without emotional overrides or hesitation.
- 01An exit plan is a scoped contract that prevents an AI agent from holding losing positions or gambling on reversals.
- 02Take-profit levels should be defined in dollar terms and staged across multiple tiers so the agent locks in gains incrementally.
- 03Stop-loss and trailing rules belong in the key scope before trading begins, not as afterthoughts once a position moves against you.
- 04Every exit plan should be validated in paper trading with hard limits before the same key is authorized for live funds.
- 05Portfolio-level exits and kill switches are essential when an agent trades across multiple markets because correlation can amplify losses suddenly.
An exit plan is a set of predefined rules that tells an AI agent exactly when to close a position, whether for profit or loss. On Felix, you encode these rules as scoped parameters attached to an API key before the agent ever sees market data. Once live, the agent evaluates price action against your plan and submits exit orders within the budget and position limits you set, removing the need for manual intervention or emotional overrides. This article walks through configuring those rules, from take-profit tiers to portfolio-wide kill switches, in the order you should implement them.
What is an exit plan and why does an agent need one?
An exit plan is the boundary between a strategy and unmanaged risk. Without it, an agent that opens a position has no instruction for when the trade is over. It might hold a losing stock for days hoping for a bounce, or close a winning crypto perp the moment it sees a small pullback. Both outcomes cost money. A proper plan states the exact conditions for closing, whether the market moves for or against you. On Felix, this plan is not a suggestion the agent reads. It is a set of hard constraints baked into the scoped API key. The agent cannot ignore them, override them, or rewrite them to chase a narrative. This matters because agents operate continuously. They do not sleep, and they do not feel fear or greed. They only do what the key allows. If you fail to set exit rules, you are not giving the agent freedom. You are giving it ambiguity, and ambiguity tends to become expensive. Many beginners focus on entry signals and forget exits entirely, which is one of the common position sizing mistakes AI agents make. A good exit plan includes at least three components: a take-profit target, a stop-loss threshold, and a maximum time limit. Some traders also add trailing stops, partial close tiers, and correlation-based portfolio exits. Each component should be defined in plain dollar terms, which the API translates into the specific contract math of the underlying venue. Remember that trading can lose money, including everything. The exit plan does not guarantee profit. It guarantees discipline.
How do you set take-profit levels before the agent opens a position?
Take-profit levels should be set before the agent enters a trade, not after you see a gain. The best way to do this is to think in dollars, not vague percentages. Suppose you allocate five hundred dollars to a single position. You might decide to close one hundred dollars of profit at the first target, two hundred at the second, and let the remainder run until a final target or a trailing stop. By staging your exits, you lock in gains incrementally rather than risking an all-or-nothing reversal. This approach also reduces the emotional temptation to move the target higher when a trade is winning. The agent does not feel temptation. It simply follows the ladder you built. On Felix, you express these levels as dollar amounts in the key scope, and the API normalizes them into the correct lot size, share count, or contract size for the specific venue. This matters because a crypto perp, an options contract, and a stock all use different unit math, but a fifty dollar profit is the same everywhere. When you set these levels, be realistic. If your take-profit target is ten percent away but your typical position only holds for a few hours, the market may rarely reach it. You can test this assumption in paper trading. Also consider the fee structure. If your target is too tight, transaction costs can eat the profit. A good rule is to set the first tier at a level that covers the worst-case round-trip fees and still leaves a net gain. The agent does not predict whether the price will hit your target. It simply watches and acts. Your job is to place the target at a level that fits your strategy and budget. If you are unsure, start with a single conservative take-profit and add tiers after you review paper trading logs. Never add tiers just because a recent trade won. Add them because the logic is repeatable.
How should you structure stop-loss and trailing rules in the API?
Stop-loss rules protect the downside, and they should be just as specific as take-profit rules. A common error is setting a stop far away to avoid being shaken out, which turns a small trade into a large loss. Another error is setting it so tight that normal noise triggers it immediately. The right distance depends on the volatility of the market and the size of your position, but a useful starting point is to risk no more than one or two percent of your total allocated budget on any single trade. That means if your budget is one thousand dollars, a single position should not lose more than ten or twenty dollars before the exit triggers. On Felix, you can configure a hard stop, a trailing stop, or both. A hard stop closes the position if the market moves against you by a specific dollar amount from your entry. A trailing stop follows the price in your favor and locks in a floor at a set distance below the highest reached value. This is useful when you want to let winners run while protecting the gains already made. The exact request schema is in the docs; the shape looks like this.
{
"tool": "set_exit_plan",
"position_id": "abc-123",
"take_profit": {"levels": [{"dollar_gain": 50, "size_usd": 100}]},
"stop_loss": {"type": "trailing", "distance_usd": 25},
"max_hold_hours": 48
}This example shows an illustrative configuration, not a live endpoint. The agent reads these parameters from the scoped key and evaluates them against the position state. If the stop condition is met, the agent submits a close order within the allowed budget. It cannot withdraw funds or redirect them. The stop is enforced by the infrastructure, not by the agent's discretion. If you trade options or perps, remember that time decay and funding rates can erode value even when the underlying price is flat. Your stop should account for this. A trailing stop is often more useful in trending markets, while a hard stop works better in range-bound conditions. You can change the style between paper trading sessions to see which fits your agent's behavior. Do not mix both on the same position unless you have a clear rule for which takes precedence, because conflicting instructions can leave the agent unsure of which boundary to respect first.
How do you test exit logic without risking real money?
Never test an exit plan with live money. Felix offers paper trading that mirrors live market conditions without exposing your capital. You should create a paper key with the exact same exit parameters you intend to use live, then run the agent for a meaningful period. A few hours is not enough. Markets cycle through high and low volatility, and you need to see how your stops and take-profit tiers behave in both. Watch for premature exits during normal wicks and for delayed exits during fast moves. If your agent hits a stop-loss ten times in a row in paper trading, your stop is likely too tight or your position size is too large for the volatility. You can adjust the plan and retest without losing a dollar. This is also the time to verify that your panic switch works. Flatten all positions and revoke the key to confirm the agent cannot continue trading. Paper trading is not a profit promise. It is a logic check. Once the behavior looks consistent, you can authorize a live key with the same scoped plan. For a full guide on setting those boundaries, see our article on how to paper trade an AI agent with hard limits.
What should you do when multiple positions need synchronized exits?
When an agent trades across multiple markets, a single position exit may not be enough. Correlations can spike suddenly, and a loss in a crypto perp can coincide with a drop in a tech stock or a prediction market contract. In these cases, you want a portfolio-level rule. Felix lets you set a total budget cap across all markets attached to one key. If the combined value drops to your threshold, the agent can flatten everything and revoke its own trading rights. This is the kill switch. You define the portfolio stop in the same scope as your individual exits. The difference is that it watches the sum of all positions rather than any single one. You should also consider synchronized take-profit. If your agent holds three positions that hedge each other, exiting one might expose the others to unplanned risk. Plan these interactions in advance. For example, you might instruct the agent to close correlated positions together if a macro event triggers. The scoped key can hold these rules, but you must think them through before you grant live access. Multi-market agents require stricter oversight because mistakes compound faster. Read more about this in how to keep a multi-market agent portfolio from blowing up.
How do you review and adjust exit plans after they run?
After your agent has run live or in paper mode, review the exit logs carefully. Look at every planned exit versus the actual fill. Did the market gap through your stop? Did the agent miss a take-profit because the level was set inside the spread? Use these observations to adjust one parameter at a time. If you change the stop distance, the take-profit tiers, and the time limit all at once, you will not know which change helped or hurt. A better approach is to run a paper session with the current plan, change one variable, run another session, and compare the outcomes. Keep in mind that a single winning or losing trade does not prove a plan is good or bad. You need a sample size across different market conditions. Also avoid the temptation to move stops further away after a loss. This is how small losses become large ones. Instead, ask whether the position was sized correctly for the volatility. Often the issue is not the exit distance but the entry size. If you find that the agent is constantly stopped out before reaching profit, you may be trading the wrong timeframe for your strategy. The exit plan is a living structure, but it should evolve slowly and based on evidence, not recent pain. For additional context on building these controls safely, see how to avoid common risk management mistakes with MCP trading agents.
Frequently asked questions
No. The exit plan is encoded into the scoped API key as a hard constraint. The agent can only submit orders that respect these boundaries. It cannot rewrite, ignore, or bypass the plan because the infrastructure validates every action against the key scope.
The agent will issue a close order as soon as the condition triggers, but it cannot guarantee a fill at the exact stop price. In fast or illiquid markets, the actual exit may be worse than the planned level. This is normal slippage, and it is why position sizing matters as much as the stop distance.
Dollar-based exits are usually clearer because the API normalizes them across stocks, crypto, perps, options, and prediction markets. A fifty dollar target means the same thing to you regardless of what the contract represents. Percentages can be useful for portfolio-level rules, but for individual positions, dollars reduce mental math.
The agent evaluates market data through MCP tools or the REST API and submits an order when the threshold is breached. Reaction time depends on data latency and venue execution speed, not on the agent's will. Plan for normal delays by not setting stops inside the typical bid-ask spread.
Yes, you can update the scoped key parameters or send a revised instruction through the API. However, frequent changes mid-trade often defeat the purpose of automation. If you find yourself constantly adjusting a live plan, it is better to flatten the position and redesign the rules in paper trading.
The dollar-sizing abstraction works the same way, but each market has unique mechanics. Options expire, perps carry funding rates, and prediction markets resolve. Your plan should include time limits and market-specific considerations alongside the profit targets.
Give your agent a key.
One key to trade stocks, crypto, perps, options, and prediction markets. Live after owner authorization.
Running a trading agent from Claude step by step seems simple, but small errors in prompts, keys, or sizing often lead to unexpected positions and losses.
AI agents trade faster than humans, but speed without controls can amplify losses. Here is how to limit execution risk without giving up custody.