设为首页收藏本站

 找回密码
 注册
查看: 1037|回复: 0
打印 上一主题 下一主题

RSI公式改得不对了,请指教 [复制链接]

Rank: 2

精华
0
UID
205387
积分
57
帖子
36
主题
21
阅读权限
30
注册时间
2015-3-17
最后登录
2016-11-12
跳转到指定楼层
1#
发表于 2016-1-29 10:03:00 |只看该作者 |倒序浏览
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
您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-24 01:37

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部