| kmcintyre Legend ![]() ![]() ![]() ![]() Posts: 410 Joined: 8/30/2007 Location: Valley Center, CA User Profile | So today I wrote an RSI() that takes into account the Linear Regression "best fit" line. Think of it as a "detrended RSI". Traditional RSI compares the close of the previous N bars. The HHV and the LLV of the N bar closes determines the total range. The RSI value for any particular close is the % that specifies where the close lies between the LLV and the HHV. HHV(C, 14) and LLV(C, 14) determines the range. RSI = (C - LLV(C(, 14) / (HHV(C, 14) - LLV(C, 14), or something like that. (I am writing this off the top of my head...) Bottom line, there is no consideration for the trend of the underlying. indLRLRSI considers the trend, as determined by the "best fit" line. Each close is measured relative to the LRL. The traditional RSI is then used to compute RSI based on "detrended" closes. How does this effect RSI? Get out your squintty glasses and look at the attached png. At the cross hair, the underlying has made a pullback in a srong bull trend. THe normal RSI shows the pullback was to 61.80. Traditionaly, this would not register as an RTM candidate. But LRLRSI shows the pullback as 38.57. This is a far more significant pullback. Anyone using Hima Reddy's "Four Zone RSI System" would recognize the latter as a "Green Zone Domination" pullback in a bullish market. I remember Jeff talking about how hard it was to get into RTM pullbacks during 2017 due to the strong bullish bias. Stocks would not pullback far enought to trigger the RTM strategies. I also recall seeeing many charts where RSI pegs in the overbought or oversold area for long periods of time as the trend rips. This is because RSI is not detrended. The strong trend overwelms the nuance of short term cycles found by RSI. Since even weak, pullback bars are higher than bars from 14 bars ago, (nearly 3 weeks ago), RSI computes a relatively high value. Detrending to eliminate the longer term trend allows RSI to reveal the nuanced, short term trend fluctuations. A word about the LRLRSI indicator. Because it only uses data in common with the LRL best fit line, LRLRSI only computes on a small part of a long term chart. Further, the RSI algorithm requires N bars to warm up. So the indicator plot shows 0 up to the start of the LRL. At that point the LRLRSI jumps to 100 as the RSI warms up. After the n bar warmup, LRLRSI starts displaying detreneded RSI values. I could write code to hide some of this (and to add overbought/oversold level lines), but I do not intend to visually inspect the LRLRSI indicator. I am using the LRL indicators for OmniScan prospecting. So as long as the LRLRSI is known at the HRE, I am happy. I have only given cursory thought to using the LRL indicators in PortSim. As written, they will not work on a historical basis. Anyway, I hope this is interesting and perhaps useful. Attached file : LRL RSI comparison.png (56KB - 307 downloads) Attached file : indLRLRSI.txt (1KB - 332 downloads) | |