exitLong(string Filter, var price, int lots)

exitShort(string Filter, var price, int lots)

Exits all long or all short trades that match the given filter condition (see below), at market or at a given price limit, until the given number of lots is closed.

exitTrade(TRADE*, var price, int lots): int

Exits a particular trade completely or partially at market or at a given price limit. Returns 0 when the order failed, otherwise nonzero.

cancelTrade(int id)

cancelTrade(TRADE*)

Cancels an open trade with a particular identifier or TRADE* pointer without sending a close order to the broker and without modifying the statistics or the balance. Useful for removing an externally closed position that was not transmitted to Zorro (f.i. on an NFA account).

Parameters:

Filter 0 or "" for closing all trades with the current algo/asset component (default).
An algo name for closing all trades with the given algo and the current asset.
An asset name for closing all trades with the given asset and the current algo.
"c" for closing all call trades with the current component.
"p" for closing all put trades with the current component.
"cp" for closing all contract trades with the current component.
"u" for closing all underlying trades with the current component.
"*" for closing all trades with the current asset.
"**" for closing all trades.
TRADE* A pointer to the trade to be closed, or ThisTrade for closing the current trade in a trade enumeration loop.
price Optional price or distance to current price for selling the position, or 0 (default) for selling at market. A positive price or price distance constitutes an exit stop, a negative price is an exit limit (similar to Entry). An exit stop closes the position when the asset price is at or worse than the given price, like a stop loss; an exit limit closes the position when the asset price is at or better than the given price, like a profit target.
lots Optional number of lots to be closed, or 0 (default) for closing all open lots. Partially closing trades is not available with some brokers.
id Identifier of the trade to be cancelled. Either the full number as assigned by the broker, or the last 4 digits as displayed in the Zorro window.

Remarks:

Example:

exitShort(0,1.234); // exits all short trades with the current Algo/Asset as soon as the price is at or above 1.234 (exit stop).

See also:

enterLong/Short, Entry, Hedge, Fill

► latest version online