nardew / talipp

talipp - incremental technical analysis library for python
https://nardew.github.io/talipp
MIT License
368 stars 59 forks source link

RSI indicator: I seem to be getting too high a value #102

Closed hoagluk closed 8 months ago

hoagluk commented 8 months ago

Hi. For the stock Intel (INTC), in my Python program, using the talipp library, I'm getting an RSI value for today (12/27/2023) of 83. My other two services, Stockcharts.com and Yahoo Finance give it an RSI of 76. Am I doing something wrong? I think I'm running talipp version 1.9.1:

image

First, my baseline, Stockcharts.com:

image

Then my program:

image

And output:

image

Thanks so much. I LOVE the library!

nardew commented 8 months ago

Hi, if I understand it right, you are providing only 28 values into the RSI indicator. That's very few. Supply at least 100 values because RSI takes older values into account (indirectly).

hoagluk commented 8 months ago

Ok, thanks. Ill

Karl Hoaglund


From: nardew @.> Sent: Thursday, December 28, 2023 3:28:44 AM To: nardew/talipp @.> Cc: Karl Hoaglund @.>; Author @.> Subject: Re: [nardew/talipp] RSI indicator: I seem to be getting too high a value (Issue #102)

Hi, if I understand it right, you are providing only 28 values into the RSI indicator. That's very few. Supply at least 100 values because RSI takes older values into account (indirectly).

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nardew_talipp_issues_102-23issuecomment-2D1870981578&d=DwMCaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=M6ywDc2cNMm6BEesXLcPM15uM1pHIosuWE-cZfUtfNA&m=f7LhWrgc3dtYG7KXjLlxNOH6TaUK9kvtILf121xyi-ABhR_UWYXC2sLDe7_-PjX5&s=S7npSM09MHfb8kWoofIsjvVwztF_C63rNAReDpUqe4s&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AB3BZ36DH7UVBLWXG2ZHSDTYLU3UZAVCNFSM6AAAAABBE4ERMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQHE4DCNJXHA&d=DwMCaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=M6ywDc2cNMm6BEesXLcPM15uM1pHIosuWE-cZfUtfNA&m=f7LhWrgc3dtYG7KXjLlxNOH6TaUK9kvtILf121xyi-ABhR_UWYXC2sLDe7_-PjX5&s=MOo-M76FDIBD_fZ9u9ucU72U2dz1cN44nc0InFBeLT4&e=. You are receiving this because you authored the thread.Message ID: @.***>

hoagluk commented 8 months ago

Sorry, I fat-fingered the send button. I'll give that a try and write you back.

Karl Hoaglund


From: Karl Hoaglund @.> Sent: Thursday, December 28, 2023 3:30:10 AM To: nardew/talipp @.>; nardew/talipp @.> Cc: Author @.> Subject: Re: [nardew/talipp] RSI indicator: I seem to be getting too high a value (Issue #102)

Ok, thanks. Ill

Karl Hoaglund 213/986-6946 (cell/text)


From: nardew @.> Sent: Thursday, December 28, 2023 3:28:44 AM To: nardew/talipp @.> Cc: Karl Hoaglund @.>; Author @.> Subject: Re: [nardew/talipp] RSI indicator: I seem to be getting too high a value (Issue #102)

Hi, if I understand it right, you are providing only 28 values into the RSI indicator. That's very few. Supply at least 100 values because RSI takes older values into account (indirectly).

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_nardew_talipp_issues_102-23issuecomment-2D1870981578&d=DwMCaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=M6ywDc2cNMm6BEesXLcPM15uM1pHIosuWE-cZfUtfNA&m=f7LhWrgc3dtYG7KXjLlxNOH6TaUK9kvtILf121xyi-ABhR_UWYXC2sLDe7_-PjX5&s=S7npSM09MHfb8kWoofIsjvVwztF_C63rNAReDpUqe4s&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AB3BZ36DH7UVBLWXG2ZHSDTYLU3UZAVCNFSM6AAAAABBE4ERMCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZQHE4DCNJXHA&d=DwMCaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=M6ywDc2cNMm6BEesXLcPM15uM1pHIosuWE-cZfUtfNA&m=f7LhWrgc3dtYG7KXjLlxNOH6TaUK9kvtILf121xyi-ABhR_UWYXC2sLDe7_-PjX5&s=MOo-M76FDIBD_fZ9u9ucU72U2dz1cN44nc0InFBeLT4&e=. You are receiving this because you authored the thread.Message ID: @.***>

hoagluk commented 8 months ago

Hi! As you suggested, I tried it with 100 historical values. That brought the number down a little, but it's still too high. (This would have signaled me out of my position about three days too early.) Here are the first and last values of my test:

image

image

In case it is helpful, I've attached a csv with the last 150 closes. This again is for INTC.

intcCloseRSI.csv

Thanks for your help!

nardew commented 8 months ago

If I run on INTC numbers over last year I am getting number 76.24498025235394 which seems correct.

hoagluk commented 8 months ago

Ah yes. That's exactly the right number.

Thank you! I'm very happy to have the solution and will happily implement it. It is a surprise, though, that so much data has to be front-loaded in order to get that indicator to work right. I don't think I've seen that with other indicators, or stated in the documentation anywhere. But thanks again for your help and for the library.

hoagluk commented 8 months ago

Ah. I also found there was an error in my program. The part indicated is incorrect:

image

It should have been "rsi[-1]". I think that is the correct way to get the latest calculated value.

I still had to front-load about 150 values to get the calculation to be correct.

nardew commented 8 months ago

Yes, indicators are accessed as standard lists.

It is not surprising at all that you may need that many values to get the same number as in the chart you pasted. Some indicators use their previous values to calculate new ones which means all input values are used in every calculation in a way. It’s not that one number was correct and the other wrong. Both were correct, just calculated on different data.