Back

RSI problems, negative values?

I'm having a couple of issues with RSI so plan to post two backtests.

This one is straightforward.  It adds SPY as an equity and defines a 14 day RSI.  On an EOD routine it logs the price and RSI value. 

Note the negative RSI values around 12/24 and the value over 100 on 1/22.  The range for RSI is 0-100 so how can this be?   Is there something wrong with the way I am defining it?

 

 

Update Backtest








0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


This is my follow up from the above. 

In this backtest I am defining a daily RSI indicator but have defined SPY equity with a minute resolution and schedule a trade window just before the close.

My expectation was that the RSI value would be updated EOD and remain unchanged until the next EOD cycle.  In the log file I output a line flagged PM for the trade window and EOD for the end-of-day cycle.  You can see in the log that the RSI is not static during the day.  I no longer have the negative (or > 100) values that were in the prior example, but the RSI values seem to be erratic.

Obviously I don't understand something and would appreciate some guidance here.

Thanks,

 

 

 

0


I guess I'm talking  to myself here, but maybe this will help someone else.  My problems seemed to go away when I specified the MovingAverageType in the RSI definition.

Basically like this:

# Changed from
self.myRSI = self.RSI(sym, 14, Resolution.Daily)
# To
self.myRSI = self.RSI(sym, 14, MovingAverageType.Wilders, Resolution.Daily)

I don't understand why, but note to self:  Always define MovingAverageType for RSI

 

1

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed