- 精华
- 0
- 在线时间
- 669 小时
- UID
- 17581
- 积分
- 5464
- 帖子
- 275
- 阅读权限
- 100
- 注册时间
- 2010-10-13
- 最后登录
- 2021-8-30
- 精华
- 0
- UID
- 17581
- 积分
- 5464
- 帖子
- 275
- 主题
- 27
- 阅读权限
- 100
- 注册时间
- 2010-10-13
- 最后登录
- 2021-8-30
|
- Params
- Numeric length1(23);
- Numeric length2(30);
- Numeric filter(10);
- Numeric units(1);
- Vars
- NumericSeries ma1(0);
- NumericSeries ma2(0);
- BoolSeries cond1(False);
- BoolSeries cond2(False);
- NumericSeries startbar1(0);
- NumericSeries startbar2(0);
- NumericSeries tobuy(0);
- NumericSeries tosell(0);
- Begin
- ma1=Average(c,length1);
- ma2=Average(c,length2);
- PlotNumeric("ma1",ma1);
- PlotNumeric("ma2",ma2);
- If(close>ma1&&close>ma2&&close[1]<Max(ma1[1],ma2[1])){
- cond1=true;
- startbar1=CurrentBar;
- tobuy=high;
- }
- If(close<ma1&&close<ma2&&close[1]>min(ma1[1],ma2[1])){
- cond2=true;
- startbar2=CurrentBar;
- tosell=low;
- }
- If(currentbar-startbar1>filter)cond1=false;
- If(currentbar-startbar2>filter)cond2=false;
- If(MarketPosition!=1&&cond1&&high>=tobuy&¤tbar!=startbar1)Buy(units,max(o,tobuy));
- If(MarketPosition!=-1&&cond2&&low<=tosell&¤tbar!=startbar2)SellShort(units,min(o,tosell));
- End
复制代码 感觉效果不怎么样 |
|