Documentation/AlgoCode/Function reference
targets
Several target distances plus display weights.
targets 100, 200, 300 split 50, 30, 20
With split, each number is a percent of the quantity that opened the position. Targets fire in the order written, one per later bar. A long hits them as price rises. A short hits them as price falls. The last target closes whatever quantity is left, including a scale-in that was added after the plan was fixed, so the weights do not have to add up to 100. Each weight must be greater than 0, and there must be one weight per target. A risk-sized entry uses that sized quantity, not a second risk calculation. Stop, trail, and breakeven stay active for the remainder. exit N percent is still a percent of the quantity left at that moment. Without split, the first target the bar touches closes the entire position. Each slice is booked at the bar close for the quantity actually closed. The trade P&L is the sum of those slices. The closing bar can still name the target or stop as the trigger.
Return value
—
Example
when ema(9) crosses above ema(21) buy stop 50 points target 20, 30, 40 points targets 100, 200, 300 split 50, 30, 20