strategy.exit

Stop and / or target for the position of entry from_entry ("" = every entry): stop and limit are prices, loss and profit distances in ticks from the entry fill. A trailing stop: trail_offset ticks behind the best price, starting once trail_price or trail_points (ticks in profit) is reached (at once with neither); it starts working from the bar after it starts. qty or qty_percent close part of the position. The first reached closes it and cancels the other. Given while the entry is still waiting, they start the moment it fills (in that bar a stop may fill, a target only when the entry filled at the open of that bar). qty limits how much it closes. Call it again to move the prices.

strategy.exit(id: string, from_entry: string = "", qty: float = na, profit: float = na, limit: float = na, loss: float = na, stop: float = na, comment: string = na, qty_percent: float = na, trail_price: float = na, trail_points: float = na, trail_offset: float = na)

Parameters

Example

strategy.exit("Exit", "Long", profit=40, loss=20)
strategy.exit("Trail", "Long", loss=20, trail_points=40, trail_offset=10)