exitLong(string algo, var price, int lots)

exitShort(string algo, var price, int lots)

Exits all long resp. all short trades with the current asset that match the given algo identifier, at market or at a given price limit, until the given number of lots is closed.

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

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

cancelTrade(int id)

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

Parameters:

algo 0 for closing all trades with the current algo/asset combination. Alternatively, an algorithm identifier, or the asset name when no algo is used in the script, or "*" for closing all trades with the current asset.
TRADE* A pointer to the trade to be closed, or 0 for closing the current trade in a trade enumeration loop.
price Optional price or price distance for selling the position, or 0 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 for closing all open lots. Partially closing trades is not available with all brokers, for instance not with NFA compliant accounts.
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, numLong/Short, Entry, Hedge, Fill

► latest version online