agorithm

1 visualizzazione (ultimi 30 giorni)
Mate 2u
Mate 2u il 11 Giu 2012
Hi there, I want to replicate the RSI function in MATLAB from tradestation (as rsindex is different).
The inputs would be a financial time series and a period N (in our example 14).
The following are the steps could anybody show me how to program this in matab. Source: http://help.tradestation.com/08_08/elword/function/rsi_function_.htm
RSI = 100 - (100/(1+RS))
RS = Average of 14 day’s closes UP / Average of 14 day’s closes DOWN*
*To calculate the first RSI value ***
Calculate the sum of the UP closes for the previous 14 days and divide this sum by 14. This is the average UP Close.
Calculate the sum of the DOWN closes for the previous 14 days and divide by 14. This is the average DOWN Close. Divide the average UP Close by the average DOWN Close. This is the Relative Strength (RS).
Add 1.00 to the RS.
Divide the result obtained in Step 4 into 100.
Subtract the result obtained in Step 5 from 100. This is the first RSI.
*To calculate the RSI each time following the first RSI value *
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.
To obtain the next average DOWN: Multiply the previous average DOWN Close by 13, add to this amount today’s DOWN Close (if any) and divide the total by 14.
Steps (3), (4), (5) and (6) are the same as for the initial RSI.

Risposte (0)

Categorie

Scopri di più su Financial Toolbox in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by