Backtest Lab Docs
Risk Management Rule Types
Risk management rules automatically monitor an open trade and close it when specific price or time-based conditions are met.
In Backtest Lab, four rule types are currently available:
- Initial Stop Loss
- Target Profit
- Dynamic (Trailing) Stop Loss
- Maximum Holding Period
The first three are price-based exit rules. These rules require a threshold price and support one or more Price Modes for determining that threshold.
The Maximum Holding Period rule is time-based and does not use a price mode.
Initial Stop Loss
An Initial Stop Loss is a protective exit that limits loss if the market moves against the trade.
It is determined when the trade is entered and does not change afterward.
For example:
- In a buy trade, the stop-loss price is below the entry price.
- In a sell trade, the stop-loss price is above the entry price.
If the market reaches the stop-loss threshold, the trade is exited.
The Initial Stop Loss is typically used to define the maximum adverse price movement the trader is willing to tolerate at the moment of entry.
Target Profit
A Target Profit is an exit rule that closes a trade when the market reaches a favorable price level.
It is used to capture gains automatically once a desired profit objective has been achieved.
For example:
- In a buy trade, the target-profit threshold is above the entry price.
- In a sell trade, the target-profit threshold is below the entry price.
If the market reaches the target threshold, the trade is exited.
Although Target Profit uses the same price-mode choices as Initial Stop Loss, its purpose is different: instead of limiting loss, it locks in a planned gain.
Dynamic (Trailing) Stop Loss
A Dynamic Stop Loss, also called a Trailing Stop Loss, is a protective exit that can move as the trade becomes profitable.
Unlike an Initial Stop Loss, which stays fixed once the trade is entered, a trailing stop adjusts in a favorable direction as the market moves in the trade's favor.
Its behavior can be understood as follows:
- For a buy trade, the trailing stop can move upward as price rises.
- For a sell trade, the trailing stop can move downward as price falls.
- If the market later reverses and reaches the trailing-stop threshold, the trade is exited.
This allows a trailing stop to serve two purposes:
- Limit risk
- Protect accumulated gains
In the current beta, Dynamic Stop Loss is available only in Distance from Entry mode.

Maximum Holding Period
A Maximum Holding Period is a time-based exit rule.
It closes a trade once the trade has remained open for longer than the configured holding duration.
This rule is useful when a strategy is intended to hold a position only for a limited period, regardless of whether the trade is currently profitable or losing.
For example, a strategy may allow a trade to remain open for a maximum of a few hours, one trading day, or several trading sessions. If the trade is still open when that limit is reached, it is automatically exited.
Unlike the other three rule types, Maximum Holding Period does not depend on a threshold price.