Docs / Build a strategy

Risk management

Stop loss, take profit, and sizing — the settings that decide how much a bad trade costs you.

Risk management bounds how much a single trade can lose and locks in gains. Every serious strategy should set at least a stop loss.

WARNING

Capital preservation is the whole game. A strategy with an excellent win rate and no stop can still be ruined by one outlier move — and a backtest run without a stop reports a drawdown you would never actually have survived.

Stop loss#

Caps the loss on a position.

TypeBehaviourKey parameter
StopLossSimpleA fixed percentage from the entry pricestoploss_pct (default -5%)
StopLossTrailingFollows price in your favour by a fixed distance, locking in profit as the trade moves your waytrailing_pct (default 0.5%)
StopLossAtrDistance scales with recent volatility (Average True Range), so the stop is wider in choppy markets and tighter in calm onesatr_multiplier (default 2.0)

Trailing stops suit trend strategies, where you want to stay in a move that keeps going. Fixed stops suit mean-reversion, where you have a specific level that invalidates the idea.

The difference is easiest to see on a trade that runs up and then pulls back.

A fixed stop stays at the entry level while a trailing stop ratchets up behind price, locking in profit when price pulls back price entry fixed stop — stays here, never triggers, gains given back trailing stop holds its high exit — profit kept
Both stops start the same distance below entry. The trailing stop climbs as price rises and then holds at its highest, so the pullback closes the trade with most of the gain banked. The fixed stop never moved — it would sit through the whole retrace.

The ATR stop is a fixed stop whose distance is set by recent volatility rather than a flat percentage: wider when the market is choppy, tighter when it is calm, so a normal wiggle doesn't stop you out but a real break does.

Take profit#

Closes a position once it reaches a target gain.

TypeBehaviourKey parameter
TakeProfitSpreadMultiple exit levels — splits the position across targets rather than closing all at onceorder_spread, an array of profit_target percentages

A spread take-profit scales out: instead of closing the whole position at one target, it closes a slice at each of several targets, banking profit along the way while leaving a runner in for a bigger move.

A spread take-profit closes half the position at plus five percent and the rest at plus ten percent entry +5% close 50% +10% close last 50% 50% still running between the targets
Half the position closes at +5%, the rest at +10%. If price stalls after the first target you have still banked half the gain; if it runs, the second half rides it. A single all-or-nothing target does neither.

A worked configuration pairing a trailing stop with a two-step target:

Stop Loss:   StopLossTrailing, trailing_pct: 2%
Take Profit: TakeProfitSpread
  - Level 1: +5%  profit → close 50%
  - Level 2: +10% profit → close the remaining 50%

Position sizing and leverage#

  • Leverage multiplies exposure — and risk. It defaults to 1. Only raise it once you understand the liquidation math for the market you are trading.
  • Size positions so that hitting your stop loss costs a small, survivable fraction of the account, not a make-or-break amount.
TIP

Set the stop loss first, then size the position from it — not the other way around. "How much do I want to buy?" is the wrong first question; "how much am I willing to lose if I'm wrong?" is the right one, and it determines the answer to the first.

Reading risk in a backtest#

Backtest with the stop in place from the start, so the reported max drawdown reflects the strategy you would actually run. Adding a stop afterwards changes which trades exist, not just their outcomes — it is a different strategy, and its old results no longer describe it.

Was this page helpful?