agorithm
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Financial Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!