Documentation/AlgoCode/Risk & exits
Risk & exits
Choose platform risk (order-monitor SL/TP) or script-driven exits from your Pine position logic.
Platform risk
Laabh’s order monitor watches live price for stop loss, take profit, trailing, and multi-target partial exits. Configure levels in the deploy UI, or declare them in Pine:
algo.risk(stoploss = 10, type = algo.points, target = 20) algo.levels(sl = 50, tp1 = 100, tp2 = 200, qty1 = 50, qty2 = 50)
With multiple targets, after the first partial take-profit Laabh can move the remaining stop to entry (breakeven).
Script risk
If your exits are custom Pine logic (strategy.exit / strategy.close) without algo.*, Laabh can use script mode: the AlgoCode worker emits exit intents when the simulated position shrinks or flats. Platform SL/TP monitoring is turned off for that strategy.
What to remember
- Order size comes from deploy settings, not Pine default quantity.
- Native
strategy.exit(stop/limit)alone does not place broker stop orders unless you are in script mode (position-based exits). - Prefer
algo.risk/algo.levelsfor clear multi-TP platform risk.