- 精华
- 0
- 在线时间
- 2366 小时
- UID
- 116737
- 积分
- 781
- 帖子
- 210
- 阅读权限
- 60
- 注册时间
- 2013-3-14
- 最后登录
- 2019-8-16
- 精华
- 0
- UID
- 116737
- 积分
- 781
- 帖子
- 210
- 主题
- 32
- 阅读权限
- 60
- 注册时间
- 2013-3-14
- 最后登录
- 2019-8-16
|
本帖最后由 yebenli 于 2014-9-17 16:42 编辑
一个做多模块,一个做空模块,同时运行就可以减少回撤。
-
- Params
- Numeric Lots(1);
-
- Vars
- NumericSeries length(20);
- NumericSeries UpBand;
- NumericSeries DnBand;
- NumericSeries MidBand;
- Begin
- IF(MarketPosition==0)
- {
- Length=20;
- }
- IF(MarketPosition<>0)
- {
- Length=Min(120,length+1);
- }
-
- UpBand=Highest(High[1],Length);
- DnBand=Lowest(Low[1],Length);
- MidBand=(UpBand+Dnband)/2;
- PlotNumeric("UpBand",UpBand);
- PlotNumeric("DnBand",DnBand);
- PlotNumeric("MidBand",MidBand);
-
- if( MarketPosition==0 )
- {
- If ( C[1]>UpBand[1] && C[2]>UpBand[2] && H>=H[1])
- {
- Buy(Lots,Max(O,H[1]) );
- }
-
- }
- //出场
- if( MarketPosition>0 && L<=midband && BarsSinceEntry>=1 )
- {
- Sell(Lots,Min(O,midband));
- }
- Commentary("length="+Text(Length));
-
- End
复制代码- Params
- Numeric Lots(1);
- Vars
- NumericSeries length(20);
- NumericSeries UpBand;
- NumericSeries DnBand;
- NumericSeries MidBand;
- Begin
-
- IF(MarketPosition==0)
- {
- Length=20;
- }
- IF(MarketPosition<>0)
- {
- Length=Min(120,length+1);
- }
- UpBand=Highest(High[1],Length);
- DnBand=Lowest(Low[1],Length);
- MidBand=(UpBand+Dnband)/2;
- PlotNumeric("UpBand",UpBand);
- PlotNumeric("DnBand",DnBand);
- PlotNumeric("MidBand",MidBand);
- if( MarketPosition==0 )
- {
-
- If ( C[1]<DnBand[1] && C[2]<DnBand[2] && L<=L[1])
- {
- SellShort(Lots,Min(O,L[1]) );
- }
- }
- if( MarketPosition<0 && H>=midband && BarsSinceEntry>=1 )
- {
- BuyToCover(Lots,Max(O,midband));
- }
- Commentary("length="+Text(Length));
-
- End
复制代码 |
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
|