由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - 请教2 period RSI(Relative Strength Index)
相关主题
empirical correlation请问currency trading一般都有什么策略?
面试这几个问题怎么回答???peer review的时候大家一般写什么strength and opportunity 呢?
关于BS物理phd转行找quant请教
转让 08 CFA Level I notes 和道明诚中文资料 模拟试题 光盘Fail 一个面试, 求大牛解惑,另外对在找工作的朋友也算是个帮助。
Dec 09 CFA level 1 pass rate declined to 34% from 46% (June 09)问个non compete的问题
有没有人知道Ziff Brothers Investment?新手请教trade volatility
欢迎加入每日大盘预测俱乐部出个题 (转载)
第一次电面,求指点OP演义 之 伊藤积分
相关话题的讨论汇总
话题: rsi话题: nperiod话题: data话题: period话题: average
进入Quant版参与讨论
1 (共1页)
D******4
发帖数: 47
1
初次接触RSI,对于two period RSI 有点疑惑。
RSI = 100 - 100/(1+RS)
RS = Average Gain(in N period)/Average Loss(in N period)
对于2 period RSI, RS 中的N取2。
由于只有两个period,那么一定是要么gain,要么loss.
即P[1]<=P[2]时,为gain。loss为0。这时定义RSI=100.
P[1]>P[2]时,为loss.gain为0,这时RSI=0.
也就是说,2 period RSI只能取0和100两个值吗?
多谢
A***l
发帖数: 302
2
No. You made two two mistakes in the calculation:
1. RSI(2) uses two days' gains or losses, P(1)-P(0) and P(2)-P(1).
2. mean gain and mean loss are exponentional moving average,not simple movin
g average.
RSI(2) to RSI(4) are popular short-term mean reversion signals in some stats
tical arbitrage strategies.

【在 D******4 的大作中提到】
: 初次接触RSI,对于two period RSI 有点疑惑。
: RSI = 100 - 100/(1+RS)
: RS = Average Gain(in N period)/Average Loss(in N period)
: 对于2 period RSI, RS 中的N取2。
: 由于只有两个period,那么一定是要么gain,要么loss.
: 即P[1]<=P[2]时,为gain。loss为0。这时定义RSI=100.
: P[1]>P[2]时,为loss.gain为0,这时RSI=0.
: 也就是说,2 period RSI只能取0和100两个值吗?
: 多谢

D******4
发帖数: 47
3
thanks so much.~
This calculation makes sense. About MS, do I have to use EMA to calculate
RSI(2)? I tested RSI(2) in MATLAB, its own function to calculate seeme to
use Simple MA.
btw, do you know how to tackle with time series data in C++?

movin
stats

【在 A***l 的大作中提到】
: No. You made two two mistakes in the calculation:
: 1. RSI(2) uses two days' gains or losses, P(1)-P(0) and P(2)-P(1).
: 2. mean gain and mean loss are exponentional moving average,not simple movin
: g average.
: RSI(2) to RSI(4) are popular short-term mean reversion signals in some stats
: tical arbitrage strategies.

f*******y
发帖数: 988
4
已经不灵光了,现在的market vol太低了

movin
stats

【在 A***l 的大作中提到】
: No. You made two two mistakes in the calculation:
: 1. RSI(2) uses two days' gains or losses, P(1)-P(0) and P(2)-P(1).
: 2. mean gain and mean loss are exponentional moving average,not simple movin
: g average.
: RSI(2) to RSI(4) are popular short-term mean reversion signals in some stats
: tical arbitrage strategies.

A***l
发帖数: 302
5
We don't use C++. My guess is a vector of maps or a dictionary data structur
e will do.
People don't use or interpret tehnical signals in the same way. For example,
in exponential moving average, some signals use 1/N as the decay factor; ma
ny others use 1/(2N+1).
The following is a Matlab funciton that I use to calculate RSI.
function RSI = rsi(data, nPeriod, type)
% PURPOSE: calculates the relative strength indicator for data
%--------------------------------------------------------------------------
% USAGE: RSI = rsi(data, nPeriod, type)
% where: data = a vector or a matrix (RSI is calculated column by column)
% nPeriod = RSI(nPeriod)
% type = 'e' (default), calculate the first data point using simple
% moving average and then use exponential moving average with
% decay factor 1/nPeriod to update the RSI.
% 's', calculate all data points using simple moving average
% of up moves and down moves.
%--------------------------------------------------------------------------
% RETURNS: a vector or a matrix the same size as x with the first
% nPeriod-1 rows being NaN
% -------------------------------------------------------------------------
if nargin == 1
nPeriod = 14;
type = 'e';
elseif nargin == 2
type = 'e';
end
[m n] = size(data);
deltaData = data(2:m, :) - data(1:m-1,:);
positiveDelta = deltaData .* (deltaData > 0);
negativeDelta = -deltaData .* (deltaData < 0);
if type == 's'
smaPositiveDelta = sma(positiveDelta, nPeriod);
smaNegativeDelta = sma(negativeDelta, nPeriod);
RSI = smaPositiveDelta./(smaPositiveDelta + smaNegativeDelta)*100;
RSI = [nan(nPeriod,n); RSI(nPeriod:end, :)];
else
seedPositiveDelta = mean(positiveDelta(1:nPeriod, :));
positiveDelta(1:nPeriod, :) = seedPositiveDelta(ones(nPeriod,1), 1:n);
seedNegativeDelta = mean(negativeDelta(1:nPeriod, :));
negativeDelta(1:nPeriod, :) = seedNegativeDelta(ones(nPeriod,1), 1:n);

alpha = 1/nPeriod;
emaPositiveDelta = ema(positiveDelta, alpha);
emaNegativeDelta = ema(negativeDelta, alpha);
RSI = emaPositiveDelta./(emaPositiveDelta + emaNegativeDelta)*100;
RSI = [nan(nPeriod,n); RSI(nPeriod:end, :)];
end

【在 D******4 的大作中提到】
: thanks so much.~
: This calculation makes sense. About MS, do I have to use EMA to calculate
: RSI(2)? I tested RSI(2) in MATLAB, its own function to calculate seeme to
: use Simple MA.
: btw, do you know how to tackle with time series data in C++?
:
: movin
: stats

D******4
发帖数: 47
6
Thanks a lot.
I was given the assignment to implement a "test trading strategy" in
C++. Since this is my first try, I plan to write the code in MATLAB
first, then think about how to design the class in C++.
I've also written the function to calculate RSI, but not good as yours.

structur
example,
factor; ma

【在 A***l 的大作中提到】
: We don't use C++. My guess is a vector of maps or a dictionary data structur
: e will do.
: People don't use or interpret tehnical signals in the same way. For example,
: in exponential moving average, some signals use 1/N as the decay factor; ma
: ny others use 1/(2N+1).
: The following is a Matlab funciton that I use to calculate RSI.
: function RSI = rsi(data, nPeriod, type)
: % PURPOSE: calculates the relative strength indicator for data
: %--------------------------------------------------------------------------
: % USAGE: RSI = rsi(data, nPeriod, type)

l*********o
发帖数: 3091
7
RSI 也能赚钱?
1 (共1页)
进入Quant版参与讨论
相关主题
OP演义 之 伊藤积分Dec 09 CFA level 1 pass rate declined to 34% from 46% (June 09)
What periodicals or blogs related to trading do you read?有没有人知道Ziff Brothers Investment?
Beyond a practical trading period 是啥意思?欢迎加入每日大盘预测俱乐部
notification period.第一次电面,求指点
empirical correlation请问currency trading一般都有什么策略?
面试这几个问题怎么回答???peer review的时候大家一般写什么strength and opportunity 呢?
关于BS物理phd转行找quant请教
转让 08 CFA Level I notes 和道明诚中文资料 模拟试题 光盘Fail 一个面试, 求大牛解惑,另外对在找工作的朋友也算是个帮助。
相关话题的讨论汇总
话题: rsi话题: nperiod话题: data话题: period话题: average