Skip to main content

trailing_stop

Function trailing_stop 

Source
pub fn trailing_stop(trail_pct: f64) -> TrailingStop
Expand description

Create a trailing stop condition.

The trailing stop tracks the best price (highest for longs, lowest for shorts) since position entry and triggers when price retraces by the specified percentage.

§Example

use finance_query::backtesting::condition::*;

// Exit if price drops 3% from the highest point since entry
let exit = trailing_stop(0.03);