Trade management
Breakeven, partial closes, trailing stops and exits.
Management is written under the order it belongs to, as an indented block after the order line.
when liquidity_grab.completed from 08:00 to 11:00 Europe/London:buy risk: 1%, stop: liquidity_grab.sweep.low - 3 points, target: 2R + 5 pips, tag: "breakout":breakeven at: 1R, offset: 2 pipspartial 30% at: 1.5Rpartial 30% at: 2.5Rtrail by: atr(14), after: 2Rexit after: 48 barsexit when: crosses_below(close, ema(close, 20))| Line | What it does | Rule |
|---|---|---|
breakeven | Moves the stop to the entry price, plus an optional offset, once a level is reached. | E13 |
partial | Closes part of the original size at a level. Each partial fires once. | E15 |
trail | Follows the best price reached by a distance, after a level. It only ever tightens. | E14 |
exit | Closes after a number of bars, a length of time, or when a condition is true. | E16 |
You can also manage trades from anywhere with a loop over trades.open(...), using close and modify. Example: Active Trade Manager.
Rules about a trade that is still open
An open trade knows how long it has been open and where it stands. trades.last() is the trade being held when there is one, bars_open counts its bars, and r is its result so far measured against its own risk.
when close > open:buy risk: 1%, stop: 50 pips, target: 4Rwhen trades.last().bars_open > 3:close_all