Trade Mode, Phantom Trades, Equity Curve Trading

Zorro supports phantom trades that are not sent to the broker, but internally simulated. No real money is invested. Instead, the win or loss of a phantom trade is calculated from the price curve and the current 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 can be used for equity curve trading and for Virtual Hedging. In the latter case they are automatically handled and do not contribute to the statistics.

Equity curve trading is a method of limiting losses by detecting and 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 the equity curve shows that the market is getting profitable again. So Zorro 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. But it can often reduce the risk of a system. 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. According to our experience, equity curve trading often makes not much difference in backtests, but can make a difference in live trading.

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_ACCOUNT
- enter trades on the main account from the [Account] scroll box; use the account from the asset list only as price source.
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