closeAllPositions
Closes every position this algorithm has open, at the market. The same as OPEN_POSITIONS.closeAll().
Trading on margin can lose you more than you put in. Past results, including backtests, do not predict future results. Cloud9Trader provides tools and education, not financial advice.
declare function closeAllPositions(): void;Returns
Section titled “Returns”Nothing. Each close goes to your broker; the positions leave OPEN_POSITIONS as they close.
Example
Section titled “Example”function onTick() { const fridayEvening = TIME.getUTCDay() === 5 && TIME.getUTCHours() >= 20; if (fridayEvening && OPEN_POSITIONS_COUNT > 0) { closeAllPositions(); }}Related
Section titled “Related”- Position: close one position with
position.close().