RSI Calculation: Consecutive Down Days

Discussion in 'Technical Analysis' started by spinoza, Feb 24, 2007.

  1. spinoza


    Can any mathematically inclined trader explain how RSI calculations work with ALL consecutive down days within the defined period (i.e. No Up days during test period). Seems like you would get RSI=0, but that does not happen with TradeStation platform or at

    Below is how 5 day RSI is calculated with both Up and Down days within sample period. However, with RSI = 100.0 - (100.0 / (1.0+RS)) and RS = SUM_GAINS / SUM_LOSSES. When there are NO Up days(no gains) then SUM_GAINS=0, which should make RS=0, and thus RSI=0. But on a series of ONLY Down days, (or ONLY Up days) within the defined period, there are NON-ZERO RSI values generated on sources such as TradeStation and

    Why are non-zero RSI values generated with All consecutive DOWN days within the defined period(or ALL UP days)?

    RSI Formula
    SUM_GAINS = sum of gains over last D days (including today).
    SUM_LOSSES = sum of losses over last D days (including today).
    RSI = 100.0 - (100.0 / (1.0+RS))

    5-Day RSI Example
    Date Gain Loss
    ---- ---- ----
    01/03/89 1.1% 0.0%
    01/04/89 0.5% 0.0%
    01/05/89 0.0% 0.9%
    01/06/89 1.3% 0.0%
    01/07/89 0.0% 1.5%

    SUM_GAINS = 0.58%
    SUM_LOSSES = 0.48%

    RS = 1.21
    RSI = 54.75
  2. one line of code is missing...perhaps one will post it...I will review code from a site that I trust and if I can find out I will try...

  3. RSI = 100 - 100 / (1 + RS)
    RS = AG / AL
    AG = Average Gain over RSI Period
    Gain = Price - Price.x (when Price > Price.x)
    AL = Average Loss over RSI Period
    Loss = Price - Price.x (when Price < Price.x)
    x = Momentum Period
    An optional smoothing is applied to the resulting RSI values. If no smoothing is desired, specify a smoothing period of 1.

    "Morris Modified" , the average loss and average gain will only be computed over the Period specified (Simple Smoothing), otherwise the averages are cumulative (Exponential Smoothing). The resulting RSI can be optionally smoothed. The momentum period used to determine Gains and Losses defaults to 1, but can be adjusted to periods greater than 1.
  4. doli



    How about

    RS = average of net UP closing changes for a selected no. of days /
    average of net DOWN closing changes for the same no. of days

    That's from Elder's book.
  5. apparantly we are dealing with averages...
  6. According to the explanation of the formula given in this PDF on technical analysis, the calculation is a simple one and is based on a basic +1/-1 absolute number assigned to the RSI based on whether the frame of refrence being observed has a positive or negative value.

    This value is assigned regardless of the momentum (or lack) of the move.

    Here's the PDF Technical Analysis

    Here's a spreadsheet using the formula listed in the PDF ...
  7. ... and here's a chart using the basic RSI.

    The values are always re-caculated based on whatever period you are using, so if you do not see the same setup in your trading application, I would check with the technicians who put together their formulas (that's what I always do with Quotetracker when I have a question/problem).

    Good trading,

  8. Hi spinoza,

    Something not quite right with the formula you have.

    From page 65 of J. Welles Wilders, Jr's book:
    New Concepts in Technical Trading Systems


    The Relative Strength Index Equation

    The equation for the Relative Strength Index, RSI, is:

    RSI = 100 - (100/(1 + RS))

    RS = Average of 14 day's closes UP/Average of 14 day's closes DOWN

    For the first calculation of the Relative Strength Index, RSI, we need the previous 14 day's close prices. From then on, we need only the previous day's data. The initial RSI is calculated as follows:

    (1) Obtain the sum of the UP closes for the previous 14 days and divide this sum by 14. This is the average UP close.

    !2) Obtain the sum of the DOWN closes for the previous 14 days and divide this sum by 14. This is the average DOWN close.

    (3) Divide the average UP close by the average DOWN close. This is the Relative Strength (RS).

    (4) Add 1.00 to the RS.

    (5) Divide the result obtained in Step 4 into 100.

    (6) Subtract the result obtained in Step 5 from 100. This is the first RSI.

    From this point on, it is only necessary to use the previous average UP close and the previous average DOWN close in the calculation of the next RSI. This procedure, which incorporates the dampering or smoothing factor into the equation, as as follows:

    (1) To obtain the next average UP close:
    Multiply the previous average UP close by 13, add to this amount today's UP close (if any) and divide the total by 14.

    (2) To obtain the next average DOWN close:
    Multiply the previous average DOWN close by 13, add to this amount today's DOWN close (if ant) and divide the total by 14.

    Steps (3), (4), (5) and (6) are the same as the initial RSI.


    So, the reason why you do not get the 0 or 100 readings is because of the "dampering or smoothing factor" in the equation.

    Wilders was showing the calculation of a 14-day RSI. For your case of a 5-day RSI you can substitute 4 for 13 and 5 for 14 in the above steps.

    Additionally, I wrote a mini series of 3 articles on the correct usage of the RSI as taught by Wilders in his book. A lot of what is taught in other books and Internet are wrong.

    Hope this helps.
  9. Hi spinoza,

    Step (1) and (2) will show why you will not get a RSI value of 0 even when all 5 days are DOWN close (for 5-day RSI). Similar you will not get a RSI value of 100 even when all 5 days are UP close (for 5-day RSI).

    In your first post, I think you mentioned you use TradeStation. The RSI EZL code is correct as per Wilders' formula. You can open it and see the calculation.
  10. spinoza


    Thanks..I got it...The running average Up close value is used from days before the period of consecutive all Down days.

    I have found RSI to give nice standardized measurements of overall price momentum.

    Thanks for everyone's comments.
    #10     Feb 25, 2007