DYO: RSI Uptrend / Downtrend example


Q:  I was wondering if you could give me some hints on getting a study added to my charts.  I suspect this can be done very easily, but I'm not much of a programmer-type and I'm not sure where to start with this.  Below is a description of the study and Amibroker code for making it work in that program (which I don't own), but I would like to try to add it to my Ensign charts to see if it can be of any help.  Could you get me started in the right direction to get the correct histograms working in Ensign?  Thanks

Uptrend

For starters, we will use a 9 period RSI.  The first step is to determine how many periods have passed since the RSI went above 70 and how many periods have passed since it went below 30.   If there have been fewer periods since it was above 70, then we check to see if the lowest value of RSI since that point is still above 40.  If this is the case, then we have a confirmed uptrend.  It began when the RSI value first exceeded 70 and continues so long as the lowest RSI value stays above 40.

Downtrend

To identify a down trend, again we use a 9 period RSI.  Then we determine how many periods have gone by since the RSI went above 70 and how many periods have passed since it went below 30.  If there have been fewer periods since it was below 30, then we check to see if the highest value of RSI since that point is still below 60.  If this is the case then we have a confirmed downtrend.  It began when the RSI value first fell below 30 and continues so long as the highest RSI value stays below 60.

Trading Range

The trading range is simple to detect.  We find it be default.  When an uptrend ends, but a downtrend is not detected by the above criteria, a trading range has been established.  Of course, the opposite is true too.  When a downtrend ends, but an uptrend does not show itself, a trading range has been established. 

A Picture is Worth a Thousand Words 

The bottom window displaying green and red vertical bars indicate up and down stock trends respectively. The same window, when neither green or red bars are present, indicate a trading range. These bars are based upon the RSI requirements we have noted above. The center window is the corresponding 9 period RSI indicator with 70/30 limit lines. Lastly, the top window indicates price movement. The vertical yellow dotted lines were inserted to easily note where the trend indicating bars start and stop.   Notice how each time the trend indicating bars precede significant price movements in the stock, allowing you to take advantage of them.  Additionally, when no trend bars are present (a trading range), no significant price movement occurs in the stock.  Imagine the advantage you would have over other traders in the market if you know beforehand the trend in a stock was about to shift! 

If you use Amibroker charting software as I do, then you may copy and paste the formula below into your indicator builder to create a trend indicating window as you see above.  If you use other charting software, then you would need to write your own formula based on the criteria stated above.  Or if you must, you can decipher the trend / trading condition simply by viewing an RSI window, although as you can see above, this necessitates more scrutinizing. 

Amibroker formula 

Aup=40;
Adown=60;
up=BarsSince(RSI(9)>70);
down=BarsSince(RSI(9)<30);
Graph0=IIf(up<down,1,-1);
Graph0Style=2;
Graph0BarColor=IIf( up<down AND LLV(RSI(9),up)>Aup ,5,IIf(down<up AND HHV(RSI(9),down)<Adown,4,0));
Graph1=1.1;
Graph1Color=0;
Graph2=-1.1;
Graph2Color=0; 

The “Graph1” & “Graph2” section of the formula is only to keep the indicator scaled properly.  If you use other software, you may find that portion is not necessary. 

A:  The above can be implemented with our DYO feature using 2 DYOs and the RSI study.   This is the implementation.

Template:  1348-RSITrends


Last modified 8/8/08 12:44 PM