- 精华
- 3
- 在线时间
- 12229 小时
- UID
- 5
- 积分
- 26584
- 帖子
- 12686
- 阅读权限
- 200
- 注册时间
- 2007-7-20
- 最后登录
- 2021-11-3
- 精华
- 3
- UID
- 5
- 积分
- 26584
- 帖子
- 12686
- 主题
- 49
- 阅读权限
- 200
- 注册时间
- 2007-7-20
- 最后登录
- 2021-11-3
|
想要记录突破时的bar索引是容易的。但是,你想要表达第一次与第二次之间的差值则有很多变数。比如说,一天只上穿了一次呢?或比如说一天上穿了N次呢?如何定义第一次与第二次呢?
我用判断当前上穿与当天内上一次上穿的bar间隔数写了一个例子,可参考一下。其中以cs命名的。- Params
- Numeric boLength(20);
- Vars
- NumericSeries a;
- Numeric b;
- NumericSeries a1;
- NumericSeries cs;
- NumericSeries DonchianHi;
- NumericSeries DonchianLo;
- Bool crs;
- Begin
- b = barssincetoday;
- DonchianHi = HighestFC(High[1],boLength);
- DonchianLo = LowestFC(Low[1],boLength);
- crs = CrossOver(high,donchianhi);
- If(date!=date[1])
- {
- a =0;
- a1= 0;
- cs =0;
- }
- If(crs)
- {
- a = a+1;
- a1 = b;
- If(a>1)
- {
- cs = a1-a1[1];
- }Else
- {
- cs =0;
- }
- }
- Commentary("a="+Text(a)+ " || a1="+Text(a1)+" || cs="+Text(cs));
- End
复制代码 |
|