NthCon 函数改写求助 [开拓者 TB]
- 咨询内容:
 本帖最后由 ego90289698 于 2016-2-22 15:25 编辑 
 
 请问下各位老大, NthCon 这个函数改写问题。
 //------------------------------------------------------------------------
 // 简称: NthCon
 // 名称: 第N个满足条件的Bar距当前的Bar数目-========》需要改成 “第N个满足条件的Bar距前天的Bar数目”
 // 类别: 用户函数
 // 类型: 内建函数
 // 输出: 数值型
 //------------------------------------------------------------------------
 
 Params
 Bool Con(false);
 Numeric N(1);
 Vars
 NumericSeries PreConIndex;
 NumericSeries BarNums;
 Numeric i(0);
 Numeric ReBars(0);
 Begin
 If(Con)
 {
 BarNums = 0;
 PreConIndex = BarNums[1] + 1;
 }Else
 {
 BarNums = BarNums + 1;
 PreConIndex = BarNums;
 }
 
 ReBars = BarNums;
 For i = 2 To N
 {
 ReBars = ReBars + PreConIndex[ReBars];
 }
 
 Return ReBars;
 End
 
 //------------------------------------------------------------------------
 // 编译版本 GS2010.12.08
 // 版权所有 TradeBlazer Software 2003-2010
 // 更改声明 TradeBlazer Software保留对TradeBlazer平
 // 台每一版本的TradeBlazer公式修改和重写的权利
 //------------------------------------------------------------------------
-  TB技术人员:
高手们指点一下呗,请别潜水了。
-  TB客服:
距前天的Bar?
 
 是日线?
 这样rebars-2就好了
 
 或不是日线,前天的第几根bar?第一根?
 
-  网友回复:
 本帖最后由 bahuang 于 2016-2-25 14:39 编辑 
 
 //------------------------------------------------------------------------
 // 简称: NthConBeforeYesterday
 // 名称: 第N个符合条件,距离前天第一根bar的个数.
 // 类别: 用户函数
 // 类型: 用户函数
 // 输出: 数值型
 //------------------------------------------------------------------------
 
 
 Params
 Bool Con(false);
 Numeric N(1);
 Vars
 NumericSeries PreConIndex;
 NumericSeries BarNums;
 Numeric i(0);
 Numeric ReBars(0);
 //
 NumericSeries barCnt;
 NumericSeries barCntYesterday;
 NumericSeries barCntBeforeYesterday;
 Numeric diffBar;
 Begin
 If(Con)
 {
 BarNums = 0;
 PreConIndex = BarNums[1] + 1;
 }Else
 {
 BarNums = BarNums + 1;
 PreConIndex = BarNums;
 }
 
 ReBars = BarNums;
 For i = 2 To N
 {
 ReBars = ReBars + PreConIndex[ReBars];
 }
 //
 If(BarStatus == 0)
 {
 barCntBeforeYesterday=0;
 barCntYesterday=0;
 barCnt = 1;
 }Else If(TrueDate(0)!=TrueDate(1))
 {
 barCntBeforeYesterday=barCntYesterday;
 barCntYesterday=barCnt;
 barCnt = 1;
 }Else
 {
 barCnt=barCnt+1;
 }
 diffBar=barCntBeforeYesterday+barCntYesterday+barCnt;
 
 
 Return ReBars-diffBar;
 End
 
 
 //------------------------------------------------------------------------
 // 编译版本 GS2010.12.08
 // 用户版本 2016-02-25 11:12:33
 // 版权所有 bahuang
 // 更改声明 TradeBlazer Software保留对TradeBlazer平台
 // 每一版本的TrabeBlazer公式修改和重写的权利
 //------------------------------------------------------------------------
-  网友回复:
没测试,懒得测 不知道写的对不对 
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198  进行 有偿 编写!(不贵!点击查看价格!)
                        
相关文章
- 
                        没有相关内容
                       

 
                     会员登录/注册
会员登录/注册