Skip to content

RSI Calculation #19

@J-Addy

Description

@J-Addy

I'm a newer graduate (so I am not 100% confident in this), but I am pretty sure that the method used in this calculation is a standard weighted average instead of "Wilder's" weighted average. In order to get Wilder's we need to recursively calculate the average based on the previous averages. This can be fixed by changing the ewm method for up and down days to :

    # Calculate the EWMA for the Up days.
    self._frame['ewma_up'] = self._price_groups['up_day'].transform(
        lambda x: x.ewm(alpha=1.0 / period,adjust=False).mean()
    )

Also, when putting the Relative Strength index into the dataframe, the given method only returned values over 95. So I modified it to directly put the Relative strength index variable into the dataframe. Although, when I look at the given method, I am not sure why it doesn't work. Essentially no RSI values should ever be 0 or 100, so wouldn't the np.where statement parameters 0, 100 be essentially ignored?

    # Calculate the Relative Strength Index
    self._frame['rsi'] = 100.0 - (100.0 / (1.0 + relative_strength))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions