QQQ. 1.5 percent reverse trading system.

1. If long and today's close is higher than last highest high, then new highest high = today's close.
2. If long and today's close is lower than last highest high by more then 1.5%, then revese trade on the open next day.
3. Reverse 1 and 2 for short trades.

Profit/loss % calculated for the period from 3/10/1999 till 11/28/2011.

PL %Num of TradesAvg. Trade %
343.086280.55


Query used:
declare		@currentPrice decimal(10,2), 
			@total decimal(10,2), 
			@pos smallint, 
			@startPrice decimal(10,2), 
			@hHigh decimal(10,2), 
			@lLow decimal(10,2), 
			@currExtreme decimal(10,2), 
			@yesterClose decimal(10,2),
			@pctReverse decimal(10,2), 
			@tradeCount int

select @pos = 0, @yesterClose = 0, @pctReverse = 1.5, @total = 0, @tradeCount = 0

DECLARE @mycur CURSOR
DECLARE @close decimal(10,2), @date datetime, @open decimal(10,2)

SET @mycur = CURSOR
FOR
SELECT [qc], qo, date FROM qqq_spy where date >= '1/1/2000' order by date 
OPEN @mycur
FETCH NEXT FROM @mycur INTO @close, @open, @date
WHILE @@FETCH_STATUS = 0
BEGIN
---------------------------------
if @yesterClose = 0 set @yesterClose = @close
if @pos = 0
	begin
	set @pos = 1
	set @startPrice = @open
	set @hHigh = @close
	set @lLow = @close
	set @currExtreme = @close
	end
else
	begin
	if (100 * (@yesterClose - @currExtreme) * -@pos / @currExtreme) > @pctReverse	
		begin
		set @pos = @pos * -1
		set @total = @total + 100 * ( @open - @startPrice) * @pos / @startPrice
		set @startPrice = @open
		set @tradeCount = @tradeCount + 1
		set @currExtreme = @open
		end
	else
		begin
		if (@yesterClose - @currExtreme) * @pos > 0 
			begin
			set @currExtreme = @yesterClose 
			end
		end	
	end
set @yesterClose = @close
FETCH NEXT FROM @mycur INTO @close, @open, @date
END
DEALLOCATE @mycur

if	@tradeCount > 0		select @total, @tradeCount, cast(@total/@tradeCount as decimal(10,2))
else					select @total, @tradeCount, 0.0


theCrunchR | © 2011