Same kind of system but scaling in when prices do not rise immediately (for a 
long pos) instead of waiting for successive lower bars: I found this in the Feb 
issue of S&C and this looks very promising. On the example below I will take 
the example of a position of 1,000 shares, but entered progressively.

The system is simple: 
- buy 10% of your position (thus, 100 shares) when RSI(2) is below 25 for 2 
consecutive bars; close must be above the 200 EMA.
- buy 20% of the position if, any time after the initial buy above, close < 
ref(close,-1)
- buy 30% of the pĂ´sition if, any time after the buy above, close < 
ref(close,-1)
- buy 40% of the position if, any time after the buy above, close < 
ref(close,-1)

You now own 1,000 shares. Don't buy anymore.
Just wait and sell all when RSI(2 periods) rise above 70.

I decided to test this on Ami (and added the same rule for short positions).
My problem: on the chart, as an indicator, it seems to work well as I can see 
the successive blue buy arrows, then the blue dot for the long exit. But when I 
backtest the system, it will only buy the initial 100 shares, then stop buying!!
I used SetPositionSize to buy the appropriate number of shares in each of the 
above condition but it doesn't work in backtest.

Please see the code below and tell me what is wrong - I am struggling with this 
for days now :-( 

bull= C> EMA(C,200) AND Sum(RSI(2)< 25==2; 
bear= C< EMA(C,200) AND Sum(RSI(2)>25==2;
Buy=0;
Short= 0;

Sell=  Cross(RSI(2),70) ;
Cover=Cross(70,RSI(2)) ;
bull200= C<Ref(C,-1) AND BarsSince(Bull)<BarsSince(Sell) AND 
Ref(Sum(Bull,BarsSince(Sell)),-1)==1;
bear200= C>Ref(C,-1) AND BarsSince(bear)<BarsSince(Cover) AND 
Ref(Sum(bear,BarsSince(Cover)),-1)==1;
bull300= C<Ref(C,-1) AND Ref(Sum(Bull200,BarsSince(Sell)),-1)==1 ;
bear300= C>Ref(C,-1) AND Ref(Sum(bear200,BarsSince(Cover)),-1)==1 ;
bull400= C<Ref(C,-1) AND Ref(Sum(Bull300,BarsSince(Sell)),-1)==1 ;
bear400= C>Ref(C,-1) AND Ref(Sum(bear300,BarsSince(Cover)),-1)==1 ;
SetPositionSize(IIf(Sum(Buy,BarsSince(Sell))==1, 
100,IIf(Sum(Buy,BarsSince(Sell))==2,200,IIf(Sum(Buy,BarsSince(Sell))==3,300,IIf(Sum(Buy,BarsSince(Sell))==4,400,Null)))),4);
SetPositionSize(IIf(Sum(Short,BarsSince(Sell))==1, 
100,IIf(Sum(Short,BarsSince(Sell))==2,200,IIf(Sum(Short,BarsSince(Sell))==3,300,IIf(Sum(Short,BarsSince(Sell))==4,400,Null)))),4);
Buy= IIf(Sum(Bull,BarsSince(Sell))<4 AND Sum(Bull200,BarsSince(Sell))<4 AND 
Sum(Bull300,BarsSince(Sell))<4 AND Sum(Bull400,BarsSince(Sell))<4 ,bull OR 
bull200 OR bull300 OR bull400,Null);
Short= IIf(Sum(Bear,BarsSince(Sell))<4 AND Sum(Bear200,BarsSince(Sell))<4 AND 
Sum(Bear300,BarsSince(Sell))<4 AND Sum(Bear400,BarsSince(Sell))<4,bear OR 
bear200 OR bear300 OR bear400, Null);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);

PlotShapes(Buy*shapeUpArrow,colorBlue,0,L,-10);
PlotShapes(Short*shapeDownArrow,colorRed,0,H,-10);
PlotShapes(Sell*shapeSmallCircle,colorBlue,0,H,10);
PlotShapes(Cover*shapeSmallCircle,colorRed,0,L,-10);

Thanks in advance, please send me your feedback/corrections and enjoy the 
system also!

Carl

--- In [email protected], Bob Waits <bobwai...@...> wrote:
>
> Very interesting article in WSJ
> 
> http://bit.ly/cs0ZnU
>


Reply via email to