Friday, August 17, 2007

Stochastic Rolling Stock Systems - Countertrend oscillating systems

Stochastic Rolling Stock Systems - Countertrend oscillating systems

The following system gives good results for the SPX and for MSFT:

{Simple system that buys at the precalculated stochastic low point limit, then sells at the stochastic high point limit.
2/28/99 }

Input: len(9), sto_low(25), sto_high(75), stop_len(2);

Var: sto_low_p(1), sto_hi_p(1), {sto_low_p = the price corresponding to a stochastic value of sto_low}
buy_state(0), sell_state(0), {buy_state asks if we are currently in a buy or sell state based on whether the target price was hit}
sell_stop(0); {initial sell_stop and sell_stop lookback period}

sto_low_p = Stoch_c(LEN,STO_low); { Stoch_c( len, sto) will return the price sto% of the range above the low of
lookback period len, e.g, stoch_c( 10, 25) }
sto_hi_p = Stoch_c(LEN,STO_high);

sell_stop = lowest(low, stop_len);

if low <= sto_low_p and buy_state = 0 then begin
buy_state = 1;
sell_state = 0;
end;

if (high >= sto_hi_p) and sell_state = 0 then begin
buy_state = 0;
sell_state = 1;
end;

If buy_state = 1 then
Buy high + 1 point stop;

if (MarketPosition = 1 and BarsSinceEntry = 1) then sell_stop = Lowest(l, stop_len);

if sell_state = 1 then
ExitLong low - 1 point stop;



{ ExitLong sell_stop - 1 point stop; }

Stochastic, Rolling S&P 500 Stock Index-Daily 04/16/1998 - 03/15/2000

Performance Summary: All Trades

Total net profit $ 356.59 Open position P/L $ -2.71
Gross profit $ 500.67 Gross loss $ -144.08

Total # of trades 24 Percent profitable 67%
Number winning trades 16 Number losing trades 8

Largest winning trade $ 63.77 Largest losing trade $ -54.52
Average winning trade $ 31.29 Average losing trade $ -18.01
Ratio avg win/avg loss 1.74 Avg trade(win & loss) $ 14.86

Max consec. winners 7 Max consec. losers 2
Avg # bars in winners 6 Avg # bars in losers 11

Max intraday drawdown $ -118.87
Profit factor 3.47 Max # contracts held 1
Account size required $ 118.87 Return on account 300%

This is a decent system but has a huge drawback: it has no stop loss, nor does it identify the long-term trend. It can go long and in a sustained downtrend will not exit long since the upper range (75th percentile of price) never gets hit. Attempts to build in an automated stop such as a 2 bar low from entry, have been unsuccessful.

I improved the system as follows:

Stoch, Rolling Short:

{Simple system that buys at the precalculated stochastic low point limit, then sells at the stochastic high point limit.
2/28/99 }

Input: len(9), sto_low(25), sto_high(75), stop_len(2);

Var: sto_low_p(1), sto_hi_p(1), {sto_low_p = the price corresponding to a stochastic value of sto_low}
buy_state(0), sell_state(0), {buy_state asks if we are currently in a buy or sell state based on whether the target price was hit}
sell_stop(0), {initial sell_stop and sell_stop lookback period}
up_trend(TRUE), short_state(0); {checks if we are in an uptrend}

sto_low_p = Stoch_c(LEN,STO_low); { Stoch_c( len, sto) will return the price sto% of the range above the low of
lookback period len, e.g, stoch_c( 10, 25) }
sto_hi_p = Stoch_c(LEN,STO_high);

sell_stop = lowest(low, stop_len);

if xaverage(c, 12) < xaverage(c, 26) then up_trend = FALSE
else up_trend = TRUE;

if up_trend then
begin {** uptrend **}
if MarketPosition = -1 then ExitShort high + 1 point stop;
short_state = 0;
if low <= sto_low_p and buy_state = 0 then begin
buy_state = 1;
sell_state = 0;
end;

if (high >= sto_hi_p) and sell_state = 0 then begin
buy_state = 0;
sell_state = 1;
end;

If buy_state = 1 then
Buy high + 1 point stop;


if (MarketPosition = 1 and BarsSinceEntry = 1) then sell_stop = Lowest(l, stop_len);

if sell_state = 1 then
ExitLong low - 1 point stop;

end {** of uptrend ** }

else {** if downtrend **}
begin
if MarketPosition = 1 then ExitLong low - 1 point stop;
buy_state = 0;
if high >= sto_hi_p and short_state = 0 then begin
short_state = 1;
sell_state = 0;
buy_state = 0;
end;

if (low <= sto_low_p) and short_state = 1 then begin
short_state = 0;
buy_state = 0;
sell_state = 0;
end;

If short_state = 1 then
Sell low - 1 point stop;

if MarketPosition = -1 and short_state = 0 then
ExitShort high + 1 point stop;

end;


{ ExitLong sell_stop - 1 point stop; }


The results are excellent, although optimized for LEN = 12:

Stoch, Rolling Short S&P 500 Stock Index-Daily 04/16/1998 - 03/15/2000

Performance Summary: All Trades

Total net profit $ 534.60 Open position P/L $ -7.41
Gross profit $ 648.29 Gross loss $ -113.69

Total # of trades 19 Percent profitable 89%
Number winning trades 17 Number losing trades 2

Largest winning trade $ 84.81 Largest losing trade $ -58.08
Average winning trade $ 38.13 Average losing trade $ -56.85
Ratio avg win/avg loss 0.67 Avg trade(win & loss) $ 28.14

Max consec. winners 10 Max consec. losers 1
Avg # bars in winners 7 Avg # bars in losers 7

Max intraday drawdown $ -140.46
Profit factor 5.70 Max # contracts held 1
Account size required $ 140.46 Return on account 381%


Performance Summary: Long Trades

Total net profit $ 268.79 Open position P/L $ 0.00
Gross profit $ 382.48 Gross loss $ -113.69

Total # of trades 12 Percent profitable 83%
Number winning trades 10 Number losing trades 2

Largest winning trade $ 63.77 Largest losing trade $ -58.08
Average winning trade $ 38.25 Average losing trade $ -56.85
Ratio avg win/avg loss 0.67 Avg trade(win & loss) $ 22.40

Max consec. winners 7 Max consec. losers 2
Avg # bars in winners 6 Avg # bars in losers 7

Max intraday drawdown $ -118.07
Profit factor 3.36 Max # contracts held 1
Account size required $ 118.07 Return on account 228%


Performance Summary: Short Trades

Total net profit $ 265.81 Open position P/L $ -7.41
Gross profit $ 265.81 Gross loss $ 0.00

Total # of trades 7 Percent profitable 100%
Number winning trades 7 Number losing trades 0

Largest winning trade $ 84.81 Largest losing trade $ 0.00
Average winning trade $ 37.97 Average losing trade $ 0.00
Ratio avg win/avg loss 100.00 Avg trade(win & loss) $ 37.97

Max consec. winners 7 Max consec. losers 0
Avg # bars in winners 7 Avg # bars in losers 0

Max intraday drawdown $ -50.71
Profit factor 100.00 Max # contracts held 1
Account size required $ 50.71 Return on account 524%

No comments:

Post a Comment