Functions
strategy.close_all()
Closes the whole open position, whatever entries it came from, with a market order.
Syntax
strategy.close_all(series string comment) → void
Arguments
comment series string Return Type
void Example
//@lipi=2
strategy("strategy.close_all Example", overlay=true, initial_capital=10000, default_qty_type=strategy.fixed, default_qty_value=1)
if talib.crossover(close, talib.sma(close, 20)) {
strategy.entry("Long", strategy.long)
}
// Flatten everything when a new session starts
if session.isfirst and strategy.position_size != 0 {
strategy.close_all(comment="New session")
}