Friday, February 27, 2009

Qs SD Oscillator

Here's part of the larger standard deviation/ mean reversion system I'm putting together for the Qs as the final component of the Qs Dirty Dozen.
The system trades both long and short and, as with most of the systems I've examined recently over this backtest period, the short side produces considerably better results than the long side.
The oscillator effectively creates a rolling band of standard deviations and then looks for penetrations of the bands to trade against.
At first glance there looks like a lot of inputs, but the range of the inputs is actually very small so optimization takes place within a narrow range focused on finding the best fixed exit bars and defining lookback periods.
The equity curve is actually pretty impressive . . . until we get to December 08, which produces the first (modest) losing month. Until then, no losing months.
And then there's February . . . which is just plain dismal. On my near term "to do" list is a deconstruction of the Feb trades to determine what went wrong here and to reverse engineer some possible system improvements to relieve that drawdown. Other than Feb the system has definite possibilities.

TS2000i coding is shown below. I'll post open code in the comments section for cut and pasters. TS8.3 users know some order verbiage must be altered.

1 comment:

bzbtrader said...

Inputs: Len1(4), DP1(16), DP2(14), Len3(10), SDev(2), Len4(5), Len5(7);
Vars: AVal(0), SDX(0), Hiband(0), Loband(0);

AVal = Average(Close, Len1);
SDX = StdDev(Close, Len3) * SDev;
Hiband = AVal[DP1] + SDX;
LoBand = AVal[DP2] - SDX;

IF CurrentBar > DP1 Then Begin
Buy Next Bar at Hiband Stop;
If BarsSinceEntry = Len4 Then ExitLong This Bar at Close;
IF CurrentBar > DP2 Then Begin
Sell Next Bar at Loband Stop;
If BarsSinceEntry = Len5 Then ExitShort This Bar at Close;