Trade Mode, Phantom Trades, Equity Curve Trading

Phantom trades are simulated "what-if" trades that are not sent to the broker. Instead the win or loss of a phantom trade is calculated from the price curve and the current slippage and trading costs. It is recorded in the Short/Long statistics, but not in the Total statistics. This way the performances of phantom and real trades can be evaluated separately. Phantom trades are used for equity curve trading, for Virtual Hedging, or for both.

Equity curve trading is a method of limiting losses by skipping unfavorable market periods. For this purpose the strategy monitors the equity curves of any component of a portfolio strategy. When unusual losses are recognized, real trading with that component is suspended. For detecting whether it's worth to resume trading, the subsequent trades are then entered in phantom mode until their returns indicate that the market is getting profitable again. In this way the strategy switches in and out of phantom mode dependent on the market situation.

Several methods can be used for determining if the market it profitable or not. In the example below, the equity curve is permanently compared with its own long-term average by lowpass filtering. It the equity is below average and still falling, trading switches to phantom mode; it goes back to normal as soon as the equity curve is rising again. Other methods may be based on the balance instead of the equity curve, or on the ratio of winning to losing trades.

Equity curve trading is not a 'holy grail'. It does not improve the performance when there is no clear distinction between profitable and unprofitable market periods or when the strategy filters unprofitable periods anyway (as it should). But it can often improve the perception of a live trading system, and can prevent losses by expiration of a market inefficiency. An example of a system that suddenly became unprofitable is the 'Luxor' strategy in the script examples; here equity curve trading would have saved the day by stopping trading in December 2011.

Phantom trades and the overall trade behavior can be controlled with the following variable:

TradeMode

Determines with the flags listed below how trades are placed. Use setf and resf for setting and resetting flags.

Range:

TR_PHANTOM Enter trades in phantom mode, without sending them to the broker API.
TR_ENTRYSTOP Enter any trade with an additional stop order at distance Stop*StopFactor on NFA accounts, if supported by the broker API (see remarks). 
TR_GTC Enter trades in GTC (good-till-cancelled) mode, if supported by the broker API. Otherwise they are entered in FOK (fill-or-kill) mode.

Type:

int

Remarks:

Example (equity curve trading):

// don't trade when the equity curve goes down
// and is below its own lowpass filtered value
function checkEquity()
{
// generate equity curve including phantom trades
  vars EquityCurve = series(EquityLong+EquityShort);
  vars EquityLP = series(LowPass(EquityCurve,10));
  if(EquityLP[0] < LowPass(EquityLP,100) && falling(EquityLP))
    setf(TradeMode,TR_PHANTOM); // drawdown -> phantom trades
  else
    resf(TradeMode,TR_PHANTOM); // profitable -> normal trades
}

See also:

NFA, Hedge, Fill, broker arbitrage, setf, resf
► latest version online