Blog / How to Automate Stop-Losses on Schwab, Alpaca, and Tradier
How to Automate Stop-Losses on Schwab, Alpaca, and Tradier

You automate a stop-loss by placing the exit order at the same time you open the position, not after. At Charles Schwab, Alpaca, and Tradier that means attaching a stop or trailing-stop order the moment you buy, so the exit exists whether or not you are watching. Software can do this on every position without exception, which is the part humans reliably fail at.
What most guides skip is the harder truth: a stop order at your broker is a trigger, not a guarantee. It converts into a market order when your price is hit, and the price you actually receive can be considerably worse. Knowing where that protection ends is what separates a stop-loss that works from one that only feels reassuring.
A stop order guarantees an attempt to exit, not an exit price. The stop price triggers a market order, and in a fast or gapping market the fill can land well below it.
What is the difference between a stop, a stop-limit, and a trailing stop?
Three order types cover nearly every automated exit, and choosing wrongly is a common and expensive mistake.
- Stop order. When the price reaches your stop, a market order is submitted. You will almost certainly get out; you will not know the exact price.
- Stop-limit order. When the stop is reached, a limit order is submitted instead. You control the price, but if the market moves through your limit, the order may never fill at all and you keep the position while it falls.
- Trailing stop. The stop price follows the stock upward by a set amount or percentage and freezes when the price turns down. It locks in gains without you adjusting anything manually.
For protective exits, most people should use a plain stop or a trailing stop. A stop-limit protects you from a bad price by accepting the risk of no exit whatsoever, which is the opposite of what a protective stop is for. Our breakdown of what a trailing stop is and when to use one covers that choice in more depth.
Why does a stop-loss sometimes fill far below the stop price?
Because the stop is a trigger, not a price. The SEC's investor bulletin on stop orders is explicit: the execution price can deviate significantly from the stop price in a fast-moving market.
The clearest example is an overnight gap. Your stop sits at $48 on a stock that closes at $50. Bad news lands after the close, and the stock opens the next morning at $41. Your stop triggers correctly, but the resulting market order fills against whatever bids exist at $41. The stop did its job and you still lost far more than you planned. No stop order placed at any broker prevents this, because the market simply did not trade between $50 and $41.
FINRA makes the same point about volatile markets, and adds a second-order effect worth knowing: clusters of sell stops at obvious levels can amplify a decline as they trigger together.
How do you automate stop-losses at each broker?
We built the integrations for all three brokers below, so these are the practical mechanics rather than a features list.
Charles Schwab
Schwab supports stop, stop-limit, and trailing-stop orders, with trailing amounts set in either points or percentages. Duration matters more than people expect: a day order expires at the close, while a good-til-canceled order stays active for up to 180 calendar days before Schwab cancels it. That 180-day ceiling is the quiet failure mode. Traders set a GTC stop, forget it, and months later hold an unprotected position without any notification that the guard expired.
Alpaca
Alpaca exposes stop, stop-limit, and trailing-stop orders through its API, which is why it is the common choice for people who script their own automation. Bracket orders are also available, letting a take-profit and a stop-loss be attached to an entry as a single instruction. The tradeoff is that you are responsible for the code, the hosting, and every edge case.
Tradier
Tradier covers the same order types and adds one constraint we ran into while integrating: it does not accept dollar-amount orders, so any position sizing has to be converted into a whole share count first. It also charges per trade on its free Lite plan, which matters because every protective exit is itself a trade. We laid out that arithmetic in what automated trading actually costs.
What breaks when you manage stops by hand
Four failure patterns account for most of the damage, and all four are mechanical rather than intellectual. People know better and do it anyway.
- The stop never gets placed. The entry is exciting and the exit is admin. Positions opened in a hurry frequently have no protection at all.
- The stop gets moved down. A position approaches the stop, the trader decides the thesis is still good, and the stop slides lower. That converts a planned small loss into an unplanned large one.
- The GTC order silently expires. Schwab cancels at 180 days. Other brokers use shorter windows. Nothing alerts you that the position is now naked.
- Winners run without protection. A stop set at entry stays at entry. The position doubles and the stop still sits at the original level, protecting a gain that no longer reflects reality. A trailing stop solves this, and almost nobody adjusts manually.
These are the exact behaviors that make a written trading plan and an executed trading plan two different documents. We covered the psychology in why most traders lose money and the specific cost of holding losers in how to cut trading losses faster.
What we learned building automated exits
Placing a stop order is straightforward. Managing exits reliably is not, and the difficulty is almost entirely in the edge cases.
The problem that consumed the most engineering time was preventing duplicate sells. Several independent processes can each decide a position should be closed within the same few seconds, and without a lock they all submit, so the broker receives multiple sell orders for shares you own once and rejects the surplus as oversells. The fix is unglamorous: a short-lived lock so the first decision wins and the others stand down.
The second lesson was about honesty in failure. An early version marked a position closed in our own records when the broker sell did not actually succeed. The dashboard reported an exit that had not happened while the broker still held the shares, which is worse than no automation at all. We rewrote it so that nothing is ever recorded as closed unless the broker confirms it, and repeated failures halt automatic exits and tell the user rather than silently retrying. A system that lies about protecting you is more dangerous than one that admits it is stuck.
What automation cannot protect you from
Two limits are worth stating plainly, because software marketing rarely does.
Gaps remain unavoidable. No stop order, automated or manual, protects against a price that never trades. Position sizing is the only real defense: if a 40% overnight gap would be catastrophic for your account, the position was too large regardless of where the stop sat.
Automation also cannot make a bad rule good. A stop placed 1% below entry on a volatile stock will trigger on ordinary noise, and executing that rule flawlessly a hundred times simply produces a hundred small losses. The software follows your instructions; it does not audit whether they make sense.
If you want to see how a rules-based configuration would look for your situation, you can set your risk rules and watch what the AI would do before committing to anything.
Frequently asked questions
Can I automate stop-losses on Charles Schwab?
Yes. Schwab supports stop, stop-limit, and trailing-stop orders that you can attach to a position. Note that good-til-canceled orders remain active for up to 180 calendar days, after which Schwab cancels them and the position is unprotected until you place a new one.
Does a stop-loss guarantee I will not lose more than planned?
No. A stop order triggers a market order at your stop price, and the fill can be materially worse in fast markets or after an overnight gap. The SEC states this directly in its investor bulletin on stop orders.
Should I use a stop-loss or a stop-limit order?
For protective exits, generally a plain stop or trailing stop. A stop-limit lets you control the exit price but can fail to fill entirely if the market moves through your limit, leaving you holding a falling position.
Where should I set my stop-loss?
Far enough away that normal volatility in that stock does not trigger it, and close enough that the loss is one you accepted before entering. A percentage that ignores how much the stock typically moves in a day will produce repeated small losses on noise alone.
Do trailing stops work overnight?
The order remains active, but it only trails during market sessions when the price is updating. A gap at the open triggers the stop and fills at the prevailing market price, which may be well below where the trail sat at the previous close.
Getting exits right
The value of automating a stop-loss is not that software knows a better exit price than you do. It is that software places the order every single time, never negotiates with itself when the position approaches the stop, and moves a trailing stop up while you are in a meeting.
Decide the exit before the entry, size the position so a gap cannot end you, and let something mechanical carry out the plan you made when nothing was at stake.
Keep reading
Let the AI do the trading.
Set it up in minutes. 7 day free trial on Starter and Pro.
Get started free
