Jump to content
Medved Trader Forums
  • 0

StochRSI formula parameters


Stephen

Question

The current StochRSI formula in medved trader makes assumptions about the user's desired parameters, and so does not produce as accurate results as is possible.  This in turn leads to potential false entry and exit signals.  Currently the parameters available to set are Period, St Period, and Signal.  Wilder's Smoothing is a checkmark option. Ideally, the medved trader stochrsi calc would allow for the parameters:

rsi length  - The number of bars with which the RSI is calculated.
rsi average type - The type of moving average to be used in the calculation of the RSI: simple, exponential, Wilder's.
rsi price - The type of price with which the RSI is calculated, typically the close.
k period - The period on which the highest and the lowest price values are to be found.
d period - The length of the moving average to be applied to FullK. This produces the FullD plot.
slowing period - The length of the moving average to be applied to %K. This produces the FullK plot.
average type- The type of moving average to be used in calculations: simple, exponential, Wilder's.

Chande's book "The New Technical Trader" includes his creation of the stochrsi, and is available as pdf for free at https://www.forexupload.com/670 .  See page 124:

stochRSI %k = (RSI - RSI-L) / (RSI-H - RSI-L)
stochRSI %d = SMA( %k, d_period)

where RSI-L and RSI-H are the lowest and highest values of RSI over a given look-back period.
d_period = sma length

derived from George Lane's calc of stochastic:
%k = 100 * [  ( Close(i) - L(n)  )  /  ( H(n) - L(n) ) ]
%d = SMA (%k, d_period)

where:
Close(i) = current closing price
L(n) = lowest value in last n samples
L(h) = highest value in last n samples
d_period = sma length

Other users have asked for additional formulas, but could not provide the calcs.  So this may be more information than you need, but the intent is to try to provide enough information that you can use rather than make you try to find it yourself.  The formula as shown above is sound:  I've coded this up myself using the above formula and run it against raw price data and had accurate results across every tested timeframe when compared to the stochrsi formula in packages provided by large financial brokers.  It would be great if these additional parameters could be included in the medved charting app.  Thanks.

 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Ok, comparing what you showed to MT's code:

1. to calculate actual RSI - MT uses either EMA or Wilder's EMA depending on the setting. Are you saying that SMA should be included?

2. To calculate %d (signal) - MT uses EMA. Are you saying that it should use SMA, or have an option of EMA/SMA? Or all three? Should that setting be shared with (1) above as well?

Link to comment
Share on other sites

  • 0

I made some assumptions about how MT parameters map to the ones I've used in my own app, and have listed them below.

MT period           = rsi length - The number of bars with which the RSI is calculated.
MT Smoothing = rsi average type - The type of moving average to be used in the calculation of the RSI: simple, exponential, Wilder's.
                               rsi price - The type of price with which the RSI is calculated, typically the close.
MT st period     = %k period - The period on which the highest and the lowest rsi values are to be found.  
                             - slowing_period - The length of the moving average to be applied to %k. This produces the FullK plot line.  
                                       SMA FullK = (sum of raw stochrsi values over slowing_period) / (slowing_period)
signal                 = %d period - The length of the moving average to be applied to FullK. This produces the FullD plot line.
                                      SMA FullD = (sum of FullK values over %d_period) / (%d_period)
                            - Full average type- The type of moving average to be used to calc FullK and FullD:
                               simple or exponential

So the two differences I see are that:

(1) There should be separate choices for "rsi average type" and "Full average type".  EMA, Wilder, and SMA should be choices for "rsi average type"; EMA and SMA for "Full average type."  Also, there should be separate screen controls for user selection of each "rsi average type" and "Full average type".  For example, user should be able to select EMA for one and SMA for the other.  btw, for the years I've used MT and its predecessor, I never knew until now that EMA is implemented when Use Wilder's Smoothing was unchecked.  Dropdowns seem to be more useful at reducing ambiguity.

(2) slowing_period is a parameter missing from user control in MT

Link to comment
Share on other sites

  • 0

 I don't see any place for the missing "smoothing" period value in the calculation I have. Lemme give it to you - point out what is not correct.

1. Diff = Close-Prev Close

2. AveUp = MA of positive Diffs for the last "Period" candles

AveDown = MA of negative Diffs for the last period candles (absolute value of it)

3. RS = AveUp/AveDown

4. RSI = 100 * RS / (1 + RS)    - or 100 - (100 / 1 + RS)  if you prefer

5. HH and LL are the highest and lowest values of RSI over the last "St. Period" values

6. Main = 100*(RSI-LL)/(HH-LL)

7. Signal = MA of "Signal" period of Main

8. Plot Main and Signal

I think what you are saying is that another MA is applied to the result of step 6 before step 7. But I don't see it anywhere I googled for StochRSI algorithms.

Another interesting twist I saw in some StochRSI definitions is that the HH and LL are calculated without taking into account the latest RSI value. I could do that as well but would have to know for sure that that is the correct way of doing it.

Link to comment
Share on other sites

  • 0

Those details helped me understand how MT is applying the parameters.  So yes, there is a step between 6 and 7.  Here's a reference I was able to find on tech analysis site
http://www.ta-guru.com/Book/TechnicalAnalysis/TechnicalIndicators/Stochastic.php5 .  To quote:

%K = 100*(CLOSE(i) - L(n)) / (H(n) - L(n))    [ = MT Main]

%D = SMA (%K, 3)   [ = MT MA of "Signal" period of Main ]

L(n) is the lowest low and H(n) is the highest high value in last n samples. For n is usually taken value of 14.  Lines %K and %D obtained using the above defined formula are called fast lines (%K fast, %D fast). %K slow is obtained by calculating SMA of %K fast, while formula for %D fast remains the same except it is applied on %K slow.

So %K Slow is a smoothed curve of %K Fast (aka MT Main).  %D Slow is then a signal line of %K Slow.  Earlier I called the SMA to create %K Slow the "Full average type", and said that it could be SMA or EMA.  The ta-guru site says that it is an SMA.  I use only SMA for %K Slow and %D Slow in my tech analysis, so I'd be happy if %K Slow, and in turn %D Slow, were calculated in MT solely on SMA.  Although the screen in MT does not specify, is it correct to assume that Step 7's Signal line is currently SMA?

I've been looking at a lot of stochrsi materials recently, but had not yet seen the ones about ignoring the latest rsi value.  I can't really comment on whether there's any trading signal merit to that, other than to say that it seems to be out of compliance with the vision of the original developers of RSI, Stochastic, and StochRSI.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...