- 精华
- 0
- 在线时间
- 16 小时
- UID
- 205387
- 积分
- 57
- 帖子
- 36
- 阅读权限
- 30
- 注册时间
- 2015-3-17
- 最后登录
- 2016-11-12
- 精华
- 0
- UID
- 205387
- 积分
- 57
- 帖子
- 36
- 主题
- 21
- 阅读权限
- 30
- 注册时间
- 2015-3-17
- 最后登录
- 2016-11-12
|
Params
Numeric Length(12) ;
Numeric Length(24) ;
Vars
NumericSeries NetChgAvg(12);
NumericSeries NetChgAvg(24);
NumericSeries TotChgAvg(12);
NumericSeries TotChgAvg(24);
Numeric SF(12);
Numeric SF(24);
Numeric Change( 0 );
Numeric ChgRatio(12) ;
Numeric ChgRatio(24) ;
Numeric RSI(12);
Numeric RSI(24);
Begin
If(CurrentBar <= Length(24) - 1)
{
NetChgAvg(12) = ( Close - Close[Length(12)] ) / Length(12) ;
NetChgAvg(24) = ( Close - Close[Length(24)] ) / Length(24) ;
TotChgAvg(12) = Average( Abs( Close - Close[1] ), Length(12) ) ;
TotChgAvg(24) = Average( Abs( Close - Close[1] ), Length(24) ) ;
}Else
{
SF(12) = 1/Length(12);
SF(24) = 1/Length(24);
Change = Close - Close[1] ;
NetChgAvg(12)= NetChgAvg(12)[1] + SF(12) * ( Change - NetChgAvg(12)[1] ) ;
NetChgAvg(24)= NetChgAvg(24)[1] + SF(24) * ( Change - NetChgAvg(24)[1] ) ;
TotChgAvg(12) = TotChgAvg(12)[1] + SF(12) * ( Abs( Change ) - TotChgAvg(12)[1] ) ;
TotChgAvg(24) = TotChgAvg(24)[1] + SF(24) * ( Abs( Change ) - TotChgAvg(24)[1] ) ;
}
If( TotChgAvg <> 0 )
{
ChgRatio(12) = NetChgAvg(12) / TotChgAvg(12);
ChgRatio(24) = NetChgAvg(24) / TotChgAvg(24);
}else
{
ChgRatio = 0 ;
}
RSI(12) = 50 * ( ChgRatio(12) + 1 );
RSI(24) = 50 * ( ChgRatio(24) + 1 );
PlotNumeric("RSI",RSIValue);
End
|
|