- 精华
- 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
|
由于没有设置出场,我就默认向下穿越做空- Vars
- NumericSeries ma1(0);
- NumericSeries ma2(0);
- NumericSeries conloss(0);
- NumericSeries tmphigh(0);
- NumericSeries tmplow(0);
- Begin
- //5日均线上穿10日均线做多,如果连续亏损五次,把这五次亏损的高低点区间画出来啊,然后突破再做
- If(CurrentBar<10){
- tmphigh=c;
- tmplow=c;
- return;
- }
- ma1=Average(c,5);
- ma2=Average(c,10);
- PlotNumeric("ma1",ma1);
- PlotNumeric("ma2",ma2);
- if(CrossOver(ma1,ma2)){
- If(MarketPosition==0){
- If(conloss<5)Buy(1,c);
- }
- If(MarketPosition==-1){
- If(c>LastEntryPrice)conloss=conloss+1;
- else {
- conloss=0;
- tmphigh=c;
- tmplow=c;
- }
- If(conloss<5)Buy(1,c);
- else BuyToCover(1,c);
- }
- }
- if(CrossUnder(ma1,ma2)){
- If(MarketPosition==0){
- If(conloss<5)SellShort(1,c);
- }
- If(MarketPosition==1){
- If(c<LastEntryPrice)conloss=conloss+1;
- else {
- conloss=0;
- tmphigh=c;
- tmplow=c;
- }
- If(conloss<5)SellShort(1,c);
- else Sell(1,c);
- }
- }
-
- if(conloss==5 && MarketPosition==0){
- if(high>tmphigh){
- Buy(1,Max(o,tmphigh));
- tmphigh=c;
- tmplow=c;
- conloss=0;
- }
- if(low<tmplow){
- SellShort(1,min(o,tmplow));
- tmphigh=c;
- tmplow=c;
- conloss=0;
- }
- }
- If(high>tmphigh)tmphigh=high;
- If(low<tmplow)tmplow=low;
- PlotNumeric("1",tmphigh);
- PlotNumeric("2",tmplow);
- Commentary(text(conloss));
-
-
- End
复制代码 |
|