设为首页收藏本站

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

RSI跨周期(适用于日线及以下周期) [复制链接]

Rank: 5Rank: 5

精华
0
UID
5903
积分
748
帖子
95
主题
11
阅读权限
60
注册时间
2009-11-14
最后登录
2010-11-25
跳转到指定楼层
1#
发表于 2009-12-14 16:36:37 |只看该作者 |倒序浏览

  1. //------------------------------------------------------------------------
  2. // 简称: HFRSI
  3. // 名称:
  4. // 类别: 用户函数
  5. // 类型: 用户函数
  6. // 输出: 数值型
  7. //------------------------------------------------------------------------
  8. Params
  9. Numeric Length(14) ;
  10. Numeric BigInterval(0);

  11. Vars
  12. NumericSeries BigIndex; //大周期编号
  13. NumericSeries SmallIndex; //小周期编号
  14. NumericSeries C1Diff(0);  //Close - Close[SmallIndex[1]]

  15. NumericSeries NetChgAvg;
  16. NumericSeries TotChgAvg;
  17. NumericSeries RSIValue;
  18. Numeric Change;
  19. Numeric SF;
  20. Numeric ChgRatio;
  21. Begin
  22. If(CurrentBar==0)
  23. {
  24.   BigIndex = -1;  //第1个大周期不在计算范围之内
  25.   SmallIndex = 1;
  26. }
  27. Else //If(NextOpen<>InvalidNumeric)//记录大周期的ID
  28. {
  29.   SF = 1/Length;
  30.   //当前大周期最后一根Bar
  31.   If((BigInterval==0 And T[-1]==0.09) Or (BigInterval>0 And Mod(Minute[-1],BigInterval)==0))
  32.   {
  33.    BigIndex = BigIndex[1] + 1;
  34.    SmallIndex = 1;
  35.    If(BigIndex>=1)
  36.     C1Diff = C1Diff[1] + Abs(C - C[SmallIndex[1]]); //收盘价差之和(只在<Length才使用
  37.    
  38.    //计算大周期RSI   
  39.    If(BigIndex < Length)
  40.    {
  41.     If(BigIndex[1]==-1 And BigIndex==0)
  42.      SetGlobalVar(49, C); //第1个大周期的值
  43.    }
  44.    Else If(BigIndex == Length)
  45.    {
  46.     //NetChgAvg = ( Close - Close[Length] ) / Length ;
  47.     //TotChgAvg = AverageFC( Abs( Close - Close[1] ), Length ) ;
  48.     NetChgAvg = ( C - GetGlobalVar(49)) / Length ;
  49.     TotChgAvg = C1Diff / Length;
  50.    }   
  51.    Else
  52.    {
  53.     //Change = Close - Close[1] ;
  54.     //NetChgAvg = NetChgAvg[1] + SF * ( Change - NetChgAvg[1] ) ;
  55.     //TotChgAvg = TotChgAvg[1] + SF * ( Abs( Change ) - TotChgAvg[1] ) ;
  56.     NetChgAvg = NetChgAvg[SmallIndex[1]] + SF * ( C - C[SmallIndex[1]] - NetChgAvg[SmallIndex[1]] ) ;
  57.     TotChgAvg = TotChgAvg[SmallIndex[1]] + SF * ( Abs( C - C[SmallIndex[1]] ) - TotChgAvg[SmallIndex[1]] ) ;
  58.    }
  59.    
  60.    If( TotChgAvg <> 0 )
  61.    {
  62.     ChgRatio = NetChgAvg / TotChgAvg ;
  63.    }else
  64.    {
  65.     ChgRatio = 0 ;
  66.    }
  67.    
  68.    RSIValue = 50 * ( ChgRatio + 1 ) ;
  69.   }
  70.   Else
  71.   {
  72.    BigIndex = BigIndex[1];
  73.    SmallIndex = SmallIndex[1] + 1;
  74.    C1Diff = C1Diff[1];
  75.    NetChgAvg = NetChgAvg[1];
  76.    TotChgAvg = TotChgAvg[1];
  77.    RSIValue = RSIValue[1];
  78.   }
  79. }
  80. //Commentary(Text(GetGlobalVar(49)));
  81. //Commentary("BigIndex"+Text(BigIndex));
  82. //Commentary("SmallIndex"+Text(SmallIndex));
  83. //Commentary("C1Diff"+Text(C1Diff));
  84. //Commentary("NetChgAvg"+Text(NetChgAvg));
  85. //Commentary("TotChgAvg"+Text(TotChgAvg));
  86. //Commentary(Text(RSIValue));
  87. If(BigIndex < Length)
  88.   Return InvalidNumeric;
  89. Else
  90.   Return RSIValue;
  91. End

  92. //------------------------------------------------------------------------
  93. // 编译版本 GS2004.06.12
  94. // 用户版本 2009/12/11 09:15
  95. // 版权所有 海风
  96. // 更改声明 TradeBlazer Software保留对TradeBlazer平台
  97. //   每一版本的TrabeBlazer公式修改和重写的权利
  98. //------------------------------------------------------------------------

  99. 引用
  100. Params
  101. Numeric Length(14);
  102. Numeric BigInterval(0);   //0-日线
  103. Begin
  104. PlotNumeric("HFRSI",HFRSI(Length,BigInterval));
  105. End
复制代码

[ 本帖最后由 女儿是期神 于 2009-12-14 17:03 编辑 ]

Rank: 5Rank: 5

精华
0
UID
4250
积分
891
帖子
198
主题
42
阅读权限
60
注册时间
2009-4-28
最后登录
2019-12-1
2#
发表于 2009-12-14 16:56:41 |只看该作者
楼主功底深厚  赞一个

使用道具 举报

Rank: 4

精华
0
UID
24266
积分
333
帖子
40
主题
4
阅读权限
50
注册时间
2011-1-17
最后登录
2011-10-26
3#
发表于 2011-4-20 13:45:25 |只看该作者
正寻找关于RSI跨周期函数的调用
志存心远

使用道具 举报

Rank: 5Rank: 5

精华
0
UID
85182
积分
849
帖子
302
主题
11
阅读权限
60
注册时间
2011-12-8
最后登录
2013-10-28
4#
发表于 2011-12-20 10:25:40 |只看该作者
谢谢楼主分享
http://qpic.cn/NifLLplMk若能一切随它去,便世间自在人。
      ---Derivatives

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

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

GMT+8, 2024-5-19 21:37

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部