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. If the trade was still open on the broker side, it will become orphaned and is not anymore under Zorro control. Use this function for removing an externally closed position that was not transmitted to Zorro, for instance on NFA compliant accounts.

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