双均线金叉开多平空,死叉开空平多,开仓间隔不小于50个bar [开拓者 TB]
- 咨询内容:
 本帖最后由 leosu 于 2013-6-18 12:18 编辑 
 
 求编写公式?双均线交叉,金叉开多平空,死叉开空平多,且两次多(空)间隔不小于50个bar。先谢谢了!!
-  TB技术人员:
最近 版主都忙什么 来帮帮我呀
-  TB客服:
请大家帮帮
-  网友回复:
再次顶起来 谢谢大家
-  网友回复:
本帖最后由 rucrui 于 2013-6-25 11:15 编辑 
 
 没人回复的话我来献丑吧,双均线交叉,金叉买死叉卖,买卖我都加了滑点,用的次一根开盘价避免信号闪烁。唯一你说的间隔的,描述的有点简单,我按我的理解写,就是前一个时间点开多后50根BAR内不再开多,开空同理,如果不一样自己照着我写的稍微修改代码就行。- Params
-       Numeric n1(20);
-           Numeric n2(60);
-           Numeric lots(1);
-           Numeric coverTime(50);
-                 Numeric splitRate(3);
-                 
- Vars
-           Numeric splitDot; //交易滑点
-           NumericSeries E1(0);
-           NumericSeries E2(0);
-           Numeric myprice;        
-           NumericSeries bCountTime(0);
-           NumericSeries sCountTime(0);
-           
- Begin
-           splitDot=splitRate*MinMove()*PriceScale();
-           E1=XAverage(C,n1);
-           E2=XAverage(C,n2);        
-            PlotNumeric("E1",E1,0,Red);
-            PlotNumeric("E2",E2,0,Green);
-         
-           bCountTime=bCountTime[1]+1;
-           sCountTime=sCountTime[1]+1;
-            
-           If(MarketPosition==0)
-           {
-                         If(E1[1]>E2[1] && bCountTime>coverTime)
-                         {
-                             myprice=Open+splitDot;
-                                 Buy(lots, myprice);
-                                 bCountTime=0;
-                         }
-                         else If(E1[1]<E2[1] && sCountTime>coverTime)
-                         {
-                             myprice=Open-splitDot;
-                                 Sellshort(lots, myprice);
-                                 sCountTime=0;
-                         }
-           }
-           else If(MarketPosition==1)
-           {
-                 If(E1[1]<E2[1])
-                         {
-                             myprice=Open-splitDot;
-                             Sell(lots,myprice);
-                                 If(sCountTime>coverTime)
-                                 {
-                                 Sellshort(lots, myprice);
-                                 sCountTime=0;
-                                 }
-                         }        
-           }
-           else If(MarketPosition==-1)
-           {
-                If(E1[1]>E2[1])
-                         {
-                             myprice=Open+splitDot;
-                             BuyToCover(lots,myprice);
-                                 If(bCountTime>coverTime)
-                                 {
-                                 Buy(lots, myprice);
-                                 bCountTime=0;
-                                 }        
-                         }
-           }
-           
-            Commentary("bCountTime:"+Text(bCountTime));
-            Commentary("sCountTime:"+Text(sCountTime));
- End          
 
- Params
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 1145508240  进行 有偿 编写!(不贵!点击查看价格!)
                        
相关文章
- 
                        没有相关内容
                       

 
                     会员登录/注册
会员登录/注册