RSI Bounce System

I've set up the backtest to trade at next day open - Sharing Chorlton's concerns.

There's some -ve returns in there for only a few minor tweeks in the parameters - I strongly sniff curve fitting.

I will try to do some walk forward analysis to test this.

Chorlton - do you know how I can set up a watchlist of S&P500 stocks. I'm currently set-up with the entire database. I don't know the S&P constituents and want to avoid adding them to a list one by one, if possible. Doing this will reduce the test time significantly, and weed out tiddlers which might have prohibitive spreads. It should also bring results in line with Suthers. I'm aslo not getting an equity plot - any ideas how to generate this. I'm sure it used to happen automatically without any code - now I get the pane in the chart, but with an error message.


Code;

Range1 = Optimize("Range1",200,150,250,50);
Range2 = Optimize("Range2",2,2,3,1);
Range3 = Optimize("Range3",2,2,3,1);
Range4 = Optimize("Range4",0.97,0.97,0.97,0.1);
Range5 = Optimize("Range5",5,4,6,1);


BuySig = Close > MA( Close , Range1)
AND RSI( range2 ) < range3;


// 3% limit order on close price


Buy = (Ref(BuySig,-1)==1) AND (L<range4*Ref(C,-1));
BuyPrice = range4*Ref(C,-1);

Sell = Close > MA( Close , range5 );

Short = 0;

Cover = 0;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);


e = Equity();

Plot(e,"Equity",colorRed,styleLine|styleOwnScale);

UTB
 

Attachments

  • rsi bounce portfolio optimised.csv
    10.9 KB · Views: 345
Last edited:
I've set up the backtest to trade at next day open - Sharing Chorlton's concerns.

There's some -ve returns in there for only a few minor tweeks in the parameters - I strongly sniff curve fitting.

I will try to do some walk forward analysis to test this.

Chorlton - do you know how I can set up a watchlist of S&P500 stocks. I'm currently set-up with the entire database. I don't know the S&P constituents and want to avoid adding them to a list one by one, if possible. Doing this will reduce the test time significantly, and weed out tiddlers which might have prohibitive spreads. It should also bring results in line with Suthers. I'm aslo not getting an equity plot - any ideas how to generate this. I'm sure it used to happen automatically without any code - now I get the pane in the chart, but with an error message.


Code;

Range1 = Optimize("Range1",200,150,250,50);
Range2 = Optimize("Range2",2,2,3,1);
Range3 = Optimize("Range3",2,2,3,1);
Range4 = Optimize("Range4",0.97,0.97,0.97,0.1);
Range5 = Optimize("Range5",5,4,6,1);


BuySig = Close > MA( Close , Range1)
AND RSI( range2 ) < range3;


// 3% limit order on close price


Buy = (Ref(BuySig,-1)==1) AND (L<range4*Ref(C,-1));
BuyPrice = range4*Ref(C,-1);

Sell = Close > MA( Close , range5 );

Short = 0;

Cover = 0;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);


e = Equity();

Plot(e,"Equity",colorRed,styleLine|styleOwnScale);

UTB

Hi Blades,

Regarding Watchlists, Identify the S&P constituents which you want to use (Google them, etc) and copy each of their ticker codes into Notepad on your pc. On each new line you should only have the ticker code for each stock.

I currently have a different list for the current FTSE100, FTSE250, ASX200, etc etc.

Then in AB, from the Menu, choose Symbol - WatchList - Import and choose which empty watchlist you want to attach the stock codes to. Then simply locate your notepad file and import. If you get stuck simply search for Watchlists in the online help in AB.

I don't normally use the Equity Curve in AB, as I simply export the results of the Exploration directly into TradeSim where I can plot all my charts & graphs. I will take a look at your code and get back to you though.

Side note about Optimization. Try and only optimise 2 variables at a time. Firstly, the number of steps involved is greatly reduced and secondly, when using 2 variables you can view the optimisation chart and see where the natural peaks & troughs are. This visual representation makes it very easy to make sure that the variables you finally choose will be more robust and not simply outliners (ie. values which are far away from the mean but which offer the greatest result).

Not sure if I've explained the above clearly enough but if you need further clarification let me know. Just remember that optimisation (although it is an important step in developing ones strategy) it needs to be treated with care.

Regards,

Chorlton
 
Hi Blades,

Regarding Watchlists, Identify the S&P constituents which you want to use (Google them, etc) and copy each of their ticker codes into Notepad on your pc. On each new line you should only have the ticker code for each stock.

I currently have a different list for the current FTSE100, FTSE250, ASX200, etc etc.

Then in AB, from the Menu, choose Symbol - WatchList - Import and choose which empty watchlist you want to attach the stock codes to. Then simply locate your notepad file and import. If you get stuck simply search for Watchlists in the online help in AB.

I don't normally use the Equity Curve in AB, as I simply export the results of the Exploration directly into TradeSim where I can plot all my charts & graphs. I will take a look at your code and get back to you though.

Side note about Optimization. Try and only optimise 2 variables at a time. Firstly, the number of steps involved is greatly reduced and secondly, when using 2 variables you can view the optimisation chart and see where the natural peaks & troughs are. This visual representation makes it very easy to make sure that the variables you finally choose will be more robust and not simply outliners (ie. values which are far away from the mean but which offer the greatest result).

Not sure if I've explained the above clearly enough but if you need further clarification let me know. Just remember that optimisation (although it is an important step in developing ones strategy) it needs to be treated with care.

Regards,

Chorlton

what you've sad is very clear, thanks. I'd realised the error with the optimisation almost as I hit the button, but decided to let it run for the hell of it.:D


Cheers,
UTB
 
ok, I've walk forward tested this on a basket of ETF's. There's a huge difference between results in the in sample and out of sample periods. So basically this system's performance is hammered for small changes in parameters in sample, and also doesn't test well out of sampling, or stand up to re-optimisation against changing markets.

In short, I wouldn't touch it if I were you (anyone). All IMHO.

Walk forward tests attached.

UTB
 

Attachments

  • WalkForward1.html
    6.9 KB · Views: 438
Thanks for the reply! Before I start I need to own up to a minor school boy error in my testing. Instead of refrencing yesterdays close being greater than it's 200MA, I refrenced it today. This is obviously flawed because we will only know whether that is true after the trading session, not during. Correcting the error dampened performace slightly, so I changed the entry criteria from a 3% drop to a 3.5% drop and included the following entry filter; If today's open is greater than yesterdays close then enter at 3.5% below yesterdays close, otherwise if today's open is less than or equal to yesterdays close enter at 3.5% below todays open. All the performance parameters are improved upon apart from drawdown. Number of trades decrease from 1236 to 973. All the results and equity curve are attached under "amended entries".

I used the % risk model for testing. All entries are positioned off 5% of the entry price, so if I bought at 100 my risk would be 5, and that would be divide into 1% of equity to get the position size. Because I geared the equity 10 times (assuming we're trading CFD's) your risk is magnified by 10, so if a full loss is taken you're actually loosing 10% of your account and not 1%. Because of this the system breaks down around the 2% risk mark. Some people would probaly trade at 0.5%, halving drawdown but also profit, all depends on you and your risk profile.

I ran the system through 5000 Monte Carlo simulations. The results are stable with minimal variance being experienced across the board. I have attached them under "Monte Carlo".

I'm guessing you also use metastock, if you do here is the tradesim formula so you can play around yourself;

EntryTrigger :=Ref(RSI(C,2)<2 AND C>Mov(C,200,S),-1) AND L<=If(O>Ref(C,-1),Ref(C,-1),O)*0.965;
EntryPrice :=If(O>Ref(C,-1),Ref(C,-1),O)*0.965;
ExitTrigger :=C>Mov(C,5,S);
ExitPrice :=C;
InitialStop :=entryprice*0.95;

ExtFml( "TradeSim.Initialize");
ExtFml( "TradeSim.RecordTrades",
"RSI Bounce,
LONG,
EntryTrigger,
EntryPrice,
InitialStop,
ExitTrigger,
ExitPrice,
START);

System quality number I've of heard of before, I stand to be corrected but I'm sure Van Tharp uses it. I didn't know how it was calculated, so I've allready learnt something new, thanks. If you don't mind I would like to run through the calculation with you, please correct if I'm wrong.

I'm assuming average expectancy = (% profitable*av profit)-(%loosers(av loss)

=(0.7451*9673.33)-(0.2549*9749.59)= 4722.42
or
=(0.7451*1)-(0.2549*1.0078)=0.4881... per unit

The R-multiple dist is attached, and my calculations show the stdev to be 1.210829

therefore systems quality = (0.4881...*sqrt 973)/1.21... =12.57

Ok so something is definitley wrong here. I get a more realistic figure if I divide by the stdev of returns and not r-multiple. To get the r-multpile dist I divide all the returns by 5%, this normalises losses and gains into measures of R-multiples. Is that right? Out of interest if I use the stdev of retruns the SQ number is 2.51, more realistic. I have attached the trade database with my calculations under R-multiples, have a look and let me know what you think.

Lastly, I like your idea of including a time stop. Any trade held over 13 bars is a loss, and the majority of winners occur within 7 bars. Only 14 winners occur after 7 bars so I chose that as the optimal solution. Testing with a time stop at close on the 7th bar doesn't improve performance, I tested from 3 bars up to 10 and no improvement was seen. If you think about it for a second it does make sense, the nature of the exit demands the trade to be exited on strength i.e. c>5ma, so even if the share is a loss when you exit you will be exiting on a up day recouping some of your losses. This seems to do a better job than a timed exit that could be exited on a down day. Does that make sense?

As for MAE and MFE I'll see if I can come up with any solutions.

I traded a variation of this system on the JSE top 40 for 1 year with good success. I now have stopped trading the JSE and concentrate my efforts on the American and Europen exchanges, more liquidity, better spreads etc.

If you want me to e-mail the trade database or anything else let me know. Look forward to hearing you thoughts!

I use esignal

has anyone got any efs on esignal using the rsi methodolgy?
 
Hi Suthers,

I decided to go back over this thread as I only brushed over it while I was at work. On closer examination, I picked up a few other things which confused me and would welcome some clarification.

Your ExitPrice is defined at the CLOSE. However, at this is a EOD system, you will only be aware that price has risen above the Moving Average once the Mkt is closed so surely the exit price would be the OPEN of the next day?

Hi Chorlton,

You may decide to exit on the following days open but I prefer to exit in the last 5 minute of trade during the auction. You can get a pritty clear indication whether the close will exceed the ma; simply sum the last 4 periods closing prices and add to it the last traded price in the last 5 minutes of trade and divide by 5, that will give you an good estimate of the 5ma and if the current price is greater I exit. You won't always get it right but the vast majority will be spot on.

Hope that helps
 
Hi Chorlton,

You may decide to exit on the following days open but I prefer to exit in the last 5 minute of trade during the auction. You can get a pritty clear indication whether the close will exceed the ma; simply sum the last 4 periods closing prices and add to it the last traded price in the last 5 minutes of trade and divide by 5, that will give you an good estimate of the 5ma and if the current price is greater I exit. You won't always get it right but the vast majority will be spot on.

Hope that helps

Are you actually trading this then, and if so how are your results?

My backtesting experience is extremely limited hence my results (which suggest curve fitting) could well be very unreliable!

UTB
 
ok, I've walk forward tested this on a basket of ETF's. There's a huge difference between results in the in sample and out of sample periods. So basically this system's performance is hammered for small changes in parameters in sample, and also doesn't test well out of sampling, or stand up to re-optimisation against changing markets.

In short, I wouldn't touch it if I were you (anyone). All IMHO.

Walk forward tests attached.

UTB

Hi Blades,

I'm interested in your conclusion and have a number of questions;

My system was designed for the undelying equities and not ETF, for all I know ETF's have a vastly different personality and may require a different strategy all together.
I think most importantly, though, is your conclusion being based on a total of 16 trades. I'm not sure whether you've studied or read about any form of basic statistics, but to come to any conclusion about a data set you need an absolute minimum of 30 points. Obviuosly the more the better. Your conclusion is not statistically significant and may contain an element of randomness. To get an idea of the possibilty of error divide 1 by the square route of the number of trades; 1/sqrt 16=0.25 or 25% chance of error, that's massive. Also when you say a basket of ETF how many did you use. When testing a system the ultimate goal is to produce as many trades as you can across as many instruments as you can, this creates statistical significance and confidence in the conclusions.

I tested the system across 900 different securities (sp500 midcap400) and received a total of 2209 trades. The error on that is 1/sqrt 2209=0.02 or 2%, so my test is statsitically significant and the edge very real. If you get these sort of results on 2000 or more trades then you have something that really works.

So this system is tradeable to anyone that may be interested. I am living proof!

Best Regards

Suthers
 
Are you actually trading this then, and if so how are your results?

My backtesting experience is extremely limited hence my results (which suggest curve fitting) could well be very unreliable!

UTB

Hi Blades,

I traded a variation of this system full time for 2 years with great success. The systems I trade now are based on similar ideas. I'm a full time trader and complete about 6 trades a day, 90% of my months are profitable. So play around with the system and see whether you can find any value.

Best Regards

Suthers
 
Hi Blades,

I'm interested in your conclusion and have a number of questions;

My system was designed for the undelying equities and not ETF, for all I know ETF's have a vastly different personality and may require a different strategy all together.
I think most importantly, though, is your conclusion being based on a total of 16 trades. I'm not sure whether you've studied or read about any form of basic statistics, but to come to any conclusion about a data set you need an absolute minimum of 30 points. Obviuosly the more the better. Your conclusion is not statistically significant and may contain an element of randomness. To get an idea of the possibilty of error divide 1 by the square route of the number of trades; 1/sqrt 16=0.25 or 25% chance of error, that's massive. Also when you say a basket of ETF how many did you use. When testing a system the ultimate goal is to produce as many trades as you can across as many instruments as you can, this creates statistical significance and confidence in the conclusions.

I tested the system across 900 different securities (sp500 midcap400) and received a total of 2209 trades. The error on that is 1/sqrt 2209=0.02 or 2%, so my test is statsitically significant and the edge very real. If you get these sort of results on 2000 or more trades then you have something that really works.

So this system is tradeable to anyone that may be interested. I am living proof!

Best Regards

Suthers

Hello Suthers - glad you're back.

I'am aware of the statistical significance numbers - if you look at the early in sample data, there's planty of trades. It seems that the number of trades always drops off out of sample.This could well be an error with what I'm doing and I'll look into it further.

For info, this was tested against a basket of UK stock (in error). When repeat against the ETF's I have a similar problem - plenty of trades in sample, only one out of sample. I'll look into this futher. It may be an mibroker issue - maybe Chorlton could chip in here?

Thanks for your input.

Cheers,
UTB
 
Hi Blades,

I traded a variation of this system full time for 2 years with great success. The systems I trade now are based on similar ideas. I'm a full time trader and complete about 6 trades a day, 90% of my months are profitable. So play around with the system and see whether you can find any value.

Best Regards

Suthers

Thanks again. I was interested because I wanted to make sure I'm not headiong down a blind alley. That you've got somewhere with it gves me the impetus I need!

Cheers,
UTB
 
Hi Chorlton,

You may decide to exit on the following days open but I prefer to exit in the last 5 minute of trade during the auction. You can get a pritty clear indication whether the close will exceed the ma; simply sum the last 4 periods closing prices and add to it the last traded price in the last 5 minutes of trade and divide by 5, that will give you an good estimate of the 5ma and if the current price is greater I exit. You won't always get it right but the vast majority will be spot on.

Hope that helps

Hi Suthers,

I don't want to sound pedantic but if you are monitoring the trades intraday (albeit near the end of the trading period) AND making decisions, this system isn't EOD. ;-)

However, I do appreciate why you are taking this approach though, but remember this addtitional "decision making" needs to be coded into the system as well.... IMO.

Regards,

Chorlton
 
Blades,

I'm currently playing around with this idea, with an intention to backtest it on the UK Mrkt. Due to work commitments my time is limited at the moment, but I will reply with more info in due course.......


Regards,

Chorlton
 
Hi Suthers,

I don't want to sound pedantic but if you are monitoring the trades intraday (albeit near the end of the trading period) AND making decisions, this system isn't EOD. ;-)

However, I do appreciate why you are taking this approach though, but remember this addtitional "decision making" needs to be coded into the system as well.... IMO.

Regards,

Chorlton

Chorlton,

You could also test for the difference in trading on next day's open, rather than same day close. Mt tests have been based on this.

I'd appreciate your input when you get time.

UTB

PS - I've just become a legend........:)
 
Hello All,

Okay.... Here is a very quick update. I haven't been able to dedicate too much time to this but the initial results are very disappointing when trading the UK Mrkts using EOD.

Firstly, here is the AB code which I have used:

Cond1 = RSI(2) <2 AND C >Ref(MA(C,200),-1) ;

Buysig = Cond1;

Buy = Ref(BuySig,-1) AND L<=(ValueWhen(BuySig, Close) * 0.965);
BuyPrice = ValueWhen(BuySig, Close) * 0.965;

InitStopL = BuyPrice *0.95;

SellSig1 = L <= ValueWhen(Buy,InitStopL);
SellSig2 = Close > MA(Close, 5);

SellSig = SellSig1 OR SellSig2;


Sell = Ref(SellSig ,-1);
SellPrice = Open;


I backtested both the FTSE250 & FTSE100 over the period 01/01/98 to 31/12/04. Testing on the FTSE250 roughly produced a 10% loss to starting capital over the entire period, while the FTSE100 resulted in roughly a 10% gain.

I've gone through a number of the individual trades and the Buy, Sell & Initial Stop price values seem correct.

I'll try and investigate further & post detailed results when time allows, but in the meantime can I ask Suthers to confirm that the code logic I've posted is correct.

regards,

Chorlton
 
Hello All,

Okay.... Here is a very quick update. I haven't been able to dedicate too much time to this but the initial results are very disappointing when trading the UK Mrkts using EOD.

Firstly, here is the AB code which I have used:

Cond1 = RSI(2) <2 AND C >Ref(MA(C,200),-1) ;

Buysig = Cond1;

Buy = Ref(BuySig,-1) AND L<=(ValueWhen(BuySig, Close) * 0.965);
BuyPrice = ValueWhen(BuySig, Close) * 0.965;

InitStopL = BuyPrice *0.95;

SellSig1 = L <= ValueWhen(Buy,InitStopL);
SellSig2 = Close > MA(Close, 5);

SellSig = SellSig1 OR SellSig2;


Sell = Ref(SellSig ,-1);
SellPrice = Open;


I backtested both the FTSE250 & FTSE100 over the period 01/01/98 to 31/12/04. Testing on the FTSE250 roughly produced a 10% loss to starting capital over the entire period, while the FTSE100 resulted in roughly a 10% gain.

I've gone through a number of the individual trades and the Buy, Sell & Initial Stop price values seem correct.

I'll try and investigate further & post detailed results when time allows, but in the meantime can I ask Suthers to confirm that the code logic I've posted is correct.

regards,

Chorlton

Hi Chorlton,

I agree the system isn't 100% EOD and would require some effort during the trading day. The testing, however, only uses EOD data. To make sure you're not being too optimistic you can include some negative slippage. I didn't use any slippage purely because I am able to achieve positive slippage too, which usually cancels out any negative slippage over the long term.

Your conclusions about the UK markets are correct (code looks good), I did some testing myself and the results are dissapointing. This could be due to any number of factors and your guess will be as good as mine. I'll throw a few out there for interest; Until recently the US markets could only be shorted on an uptick, making it more difficult to short. I'm not sure what the UK regulations are but this could have an effect on our testing. Many large hedgefunds in the US trade purely on mathematical models (technicals), mean reversion systems are popular as well as statistcal arbitrage. These would all contribute to the US markets tendency to revert to the mean. Lastly, technicals have been around a long time in the US and many traders follow the RSI, perhaps enough to create a self-fullfilling event. Again, this is only speculation.

The system tests well in the US, on the South African markets (where I traded a similar system) it tests unbelievably well. If I remember correctly the German and French markets tested well too. I do currently trade the UK markets but my strategy is highly propreitary and has taken many years to develop. The one thing I can tell you is that the concept is the same. Enter in dips and sell into rallies.

Out of interest, through my trading carreer I have bought many commercial systems from traders I respect, some of these include; Chuck Le Beau, Larry Connors, Van Tharp etc. The systems were all great but the minute I tested them on my local market the performance went to pieces. Out of 50 or so systems not one worked on the South African Markets. Although I gained great insight into system design, the experience led me to the conclusion that different markets have their own personalities and require different strategies. This would seem true for the US and UK with the RSI Bouncfe system.

It seems both you and blades are interested in the UK markets so I put forward a challenge to the 3 of us, lets try find something that works. I'll play around with the system and see whether I can come up with anything. I'll post my results.

Cheers for now,

Suthers
 
Thanks again. I was interested because I wanted to make sure I'm not headiong down a blind alley. That you've got somewhere with it gves me the impetus I need!

Cheers,
UTB

Hi Blades,

You may want to read my reply to Chorlton. The UK markets don't test well with this strategy and I provide a number of reasons why. For now, though, I'll play around with the parameters and see if I can come up with anything. I'm sure betwenn the 3 of us we'll get something workable.

Cheers for now,

Suthers
 
Hi Chorlton,

I agree the system isn't 100% EOD and would require some effort during the trading day. The testing, however, only uses EOD data. To make sure you're not being too optimistic you can include some negative slippage. I didn't use any slippage purely because I am able to achieve positive slippage too, which usually cancels out any negative slippage over the long term.

I agree that slippage should be included in the backtesting but for me this is a secondary requirement. Initially, the underlying strategy needs to offer adequate potential to develop further ;)

Out of interest, through my trading carreer I have bought many commercial systems from traders I respect, some of these include; Chuck Le Beau, Larry Connors, Van Tharp etc. The systems were all great but the minute I tested them on my local market the performance went to pieces. Out of 50 or so systems not one worked on the South African Markets. Although I gained great insight into system design, the experience led me to the conclusion that different markets have their own personalities and require different strategies. This would seem true for the US and UK with the RSI Bouncfe system.

I share your view that different Mrkts can (and do) exhibit their own characteristics & personalities. There is a lot written that a "robust" strategy should work on multiple Mrkts. Although, I can understand why initially this may be important, the reality (based on my limited experience) is that this is rarely the case. For example, I know of a very profitable strategy which works extemely well on the Australian Mrkt. However, when backtested on the UK Mrkt the results were less than impressive. The same goes for the current RSI Bounce system.

It seems both you and blades are interested in the UK markets so I put forward a challenge to the 3 of us, lets try find something that works. I'll play around with the system and see whether I can come up with anything. I'll post my results

Although, I do not use indicators in my own strategies, I would be happy (time-permitting) to work together on developing some ideas, as I believe this exercise could offer a good learning experience both in system development and an appreciation for the different Mrkts.

Regards,

Chorlton
 
Hi Blades,

You may want to read my reply to Chorlton. The UK markets don't test well with this strategy and I provide a number of reasons why. For now, though, I'll play around with the parameters and see if I can come up with anything. I'm sure betwenn the 3 of us we'll get something workable.

Cheers for now,

Suthers

Actually, though UK based - I'm more interested in strategies for US markets - I think the spreads involved would kill any system that trades UK stock over such a short time frame, outside the top 100.

I'm happy to test any ideas over both markets, and stay involved in whatever direction this thread takes. I'm learning and enjoying the ride:).

Cheers,
UTB
 
OK, something doesn't add up.

When I test this on the FTSE250 list I have, my results show a CAR of 25% and a RAR of 190% and a sharp of >3.

I've tested this up until present day - with just about all trades taking place for 2003 onwards.

There's been a big drawdown which I suspect corresponds with drops in the index - might suggest this strategy works best in a bull market and the 250 moved a lot in the upward phase of the equity curve.

Lack of trades prior to 2003 could match my lack of data during this period.

Equity attched.

Chorlon / Suthers- could you test this on more recent data - maybe 2003 to present and see if your results more match mine?

Cheers,
UTB
 

Attachments

  • equity.png
    equity.png
    10.2 KB · Views: 271
Top