exitTrade (TRADE* trade,var price)

Attempts to exit a trade at the given price during the next bar period.

Parameters:

trade The trade to be closed.
price Optional price limit for selling the position, or 0 for selling at market.

Remarks:

Example:

// go through all open trade positions
// and sell all losing trades
for_each_trade(trade)
{
if (isLong(trade)) {
if (trade->vPrice < priceClose(0))
exitTrade(trade);
}
if (isShort(trade)) {
if (trade->vPrice > priceClose(0))
exitTrade(trade);
}
}

See also:

exitLong, exitShort, enterLong, enterShort, numLong, numShort

► latest version online