- 精华
- 0
- 在线时间
- 908 小时
- UID
- 112594
- 积分
- 333
- 帖子
- 281
- 阅读权限
- 50
- 注册时间
- 2012-9-20
- 最后登录
- 2013-12-4
- 精华
- 0
- UID
- 112594
- 积分
- 333
- 帖子
- 281
- 主题
- 8
- 阅读权限
- 50
- 注册时间
- 2012-9-20
- 最后登录
- 2013-12-4
|
我用最简单的单均线试了一下,开仓加仓都没问题- Vars
- Numeric MinPoint;//一个最小变动单位,也就是一跳
- NumericSeries firstPrice;//第一次开仓价格
- NumericSeries LastPrice;//最后一次开仓价格
- Numeric AddSet(30);//加仓设置
- Numeric SubSet(30);//减仓设置
- Bool FirstEntryCon;//首次开仓条件lazer公式开发指南加仓减仓
- Begin
- PlotNumeric("MA50",Average(Close,50));
- FirstEntryCon=Close[2]<Average(Close[2],50) and Close[1]>Average(Close[1],50);
- MinPoint=MinMove*PriceScale;
- If(MarketPosition==0)
- {
- If(FirstEntryCon)
- {
- firstPrice=Open;
- LastPrice=firstPrice;
- Buy(2,firstPrice);
- }
- }else If(MarketPosition==1)//有多仓的情况
- {
- While(CurrentEntries<4&&High>=LastPrice+AddSet*MinPoint)//加仓
- {
- LastPrice=LastPrice+AddSet*MinPoint;
- if(Open>LastPrice)LastPrice=Open;
- Buy(1,LastPrice);
- }
- While(CurrentEntries>0&&Low<=firstPrice-SubSet*MinPoint)//减仓
- {
- firstPrice=firstPrice-SubSet*MinPoint;
- if(Open<firstPrice)firstPrice=Open;
- Sell(1,firstPrice);
- }
- }
- End
复制代码 |
|