开拓者期货期权程序化系统交易论坛

标题: 会编程,苦于无思路。只要你肯分享好的交易思路,我就免费帮你编程,实现共赢。 [打印本页]

作者: zxjt30920087    时间: 2017-7-22 08:41:40     标题: 会编程,苦于无思路。只要你肯分享好的交易思路,我就免费帮你编程,实现共赢。

会编程,苦于无思路。只要你肯分享好的交易思路,我就免费帮你编程,实现共赢。qq523305738

在此分享一个简单的系统,多品种组合效果不错。
  1. //------------------------------------------------------------------------
  2. // 简称: RRKK_C04
  3. // 名称:
  4. // 类别: 公式应用
  5. // 类型: 用户应用
  6. // 输出: Void
  7. //------------------------------------------------------------------------
  8. //说明:单均线策略
  9. //源码是交易开拓者(TB)源码,交易周期日线
  10. //交易品种:c9000、cf000、hc000、i9000、j9000、m9000、rb000、ru000、zc000等商品指数期货

  11. Params
  12.     Numeric Length1(20); //均价线长度20
  13.     Numeric S1(2);  //开仓确认周期数
  14.         Numeric S2(2);  //平仓确认周期数
  15.     Numeric Lots(1);   //交易手数1手
  16.         Numeric StartPer1(10);  //1级跟踪止盈,盈利10%启动
  17.         Numeric StopPer1(100); //1级跟踪止盈,盈利回撤100%触发
  18.         Numeric StartPer2(20); //2级跟踪止盈,盈利20%启动
  19.         Numeric StopPer2(50);  //2级跟踪止盈,盈利回撤50%触发       
  20.         Numeric StartPer3(30); //3级跟踪止盈,盈利30%启动
  21.         Numeric StopPer3(30);  //3级跟踪止盈,盈利回撤30%触发
  22.         Numeric StartPer4(50); //3级跟踪止盈,盈利50%启动
  23.         Numeric StopPer4(15);  //3级跟踪止盈,盈利回撤15%触发       
  24.         Numeric StopLoss(5); // 止损5%
  25.        
  26. Vars
  27.     NumericSeries MA1;  //均价线
  28.         Bool BuyEntry(False);
  29.         Bool SellEntry(False);       
  30.         Bool BuyExit(False);
  31.         Bool SellExit(False);
  32.     NumericSeries HighestAfterEntry;        // 开仓后出现的最高价
  33.     NumericSeries LowestAfterEntry;         // 开仓后出现的最低价

  34.        
  35. Begin
  36.     //过滤日线集合竞价
  37.         If(!CallAuctionFilter()) return;
  38.         //MA1
  39.     MA1=AverageFC(Close,Length1);
  40.             PlotNumeric("MA1",MA1);
  41.         //开平仓条件
  42.     BuyEntry=CountIf(Close[1]>MA1[1],S1)==S1;
  43.     SellEntry=CountIf(Close[1]<MA1[1],S1)==S1;
  44.     SellExit=CountIf(Close[1]>MA1[1],S2)==S2;
  45.     BuyExit=CountIf(Close[1]<MA1[1],S2)==S2;
  46.         //程序主体
  47.     If(MarketPosition!=1 && BuyEntry) //满足开多条件
  48.     {
  49.         Buy(Lots,Open);
  50.                 Commentary("开多");
  51.     }
  52.     Else If(MarketPosition!=-1 && SellEntry) //满足开空条件
  53.     {
  54.         SellShort(Lots,Open);
  55.                 Commentary("开空");               
  56.     }
  57.     Else If(MarketPosition==-1 && SellExit) //满足平空条件
  58.     {
  59.         BuyToCover(0,Open);
  60.                 Commentary("平空");
  61.     }
  62.     Else If(MarketPosition==1 && BuyExit) //满足平多条件
  63.     {
  64.         Sell(0,Open);
  65.                 Commentary("平多");
  66.     }
  67.        
  68.         //1级跟踪止盈,盈利10%启动,盈利回撤100%触发
  69.         If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer1) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer1)
  70.         {
  71.             BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer1));
  72.         }
  73.         If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer1) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer1)
  74.         {
  75.             Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer1));
  76.         }

  77.         //2级跟踪止盈,盈利20%启动,盈利回撤50%触发       
  78.         If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer2) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer2)
  79.         {
  80.             BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer2));
  81.         }
  82.         If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer2) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer2)
  83.         {
  84.             Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer2));
  85.         }
  86.        
  87.         //3级跟踪止盈,盈利30%启动,盈利回撤30%触发
  88.         If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer3) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer3)
  89.         {
  90.             BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer3));
  91.         }
  92.         If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer3) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer3)
  93.         {
  94.             Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer3));
  95.         }       
  96.        
  97.         //4级跟踪止盈,盈利50%启动,盈利回撤15%触发
  98.         If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer4) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer4)
  99.         {
  100.             BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer4));
  101.         }
  102.         If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer4) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer4)
  103.         {
  104.             Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer4));
  105.         }       
  106.        
  107.         // 启动止损
  108.         If(MarketPosition==-1 && BarsSinceLastEntry>0 && High>=LastEntryPrice*(1+StopLoss*0.01))
  109.         {
  110.                 BuyToCover(0,Max(LastEntryPrice*(1+StopLoss*0.01),Open));
  111.                 Commentary("空头亏损"+Text(StopLoss)+"%止损");
  112.         }
  113.         If(MarketPosition==1 && BarsSinceLastEntry>0 && Low<=LastEntryPrice*(1-StopLoss*0.01))
  114.         {
  115.                 Sell(0,Min(LastEntryPrice*(1-StopLoss*0.01),Open));
  116.                 Commentary("多头亏损"+Text(StopLoss)+"%止损");
  117.         }       
  118.        
  119.         //记录开仓后高低点
  120.     If(BarsSinceentry == 0)
  121.     {
  122.         HighestAfterEntry = High;
  123.         LowestAfterEntry = Low;
  124.     }else
  125.     {
  126.         HighestAfterEntry = Max(HighestAfterEntry,High); // 记录下当前Bar的最高点,用于下一个Bar的跟踪止损判断
  127.         LowestAfterEntry = Min(LowestAfterEntry,Low);    // 记录下当前Bar的最低点,用于下一个Bar的跟踪止损判断
  128.     }       
  129.        
  130.        
  131. End

  132. //------------------------------------------------------------------------
  133. // 编译版本:        2017-07-11 091043
  134. // 内核版本:        V2.6.2.14
  135. // 版权所有        zxjt30920087
  136. // 更改声明        TradeBlazer Software保留对TradeBlazer平台
  137. //                        每一版本的TradeBlazer公式修改和重写的权利
  138. //------------------------------------------------------------------------
复制代码

作者: jinxin168    时间: 2017-7-23 11:09:19

楼主,这个不错,先收藏了,不过我也是才入市的新手。
作者: wuyilin    时间: 2017-7-26 15:01:25

楼主,你这个有加滑点吗?
作者: zxjt30920087    时间: 2017-7-30 14:44:52

wuyilin 发表于 2017-7-26 15:01
楼主,你这个有加滑点吗?

程序里面没有加滑点的设置项,请在软件里面设置滑点,商品设置-交易里面。
作者: 15500390629    时间: 2017-8-10 15:43:13

前辈 可以帮我编个 价格高于前一根线高点做多 低点止损 同时开空单
作者: 15500390629    时间: 2017-8-10 15:43:46

谢谢 老师
作者: wangkun5597    时间: 2017-8-23 21:01:10

我有思路,但是编程是我的弱项,已经给你发消息了,可以的话,加我vx。
作者: zzytiancai    时间: 2017-9-3 22:24:25

已加QQ,求通过,思路绝对OK. 不过你得保密
作者: wkqh81000099    时间: 2017-9-16 19:36:12

能编写一个macd都周期共振的指标吗
作者: jinzhiyuan    时间: 2017-9-25 22:02:54

顶一下楼主
作者: zxjt30920087    时间: 2017-11-16 08:15:28

声明:经过一段期间的磨合,我已找到好的策略。这段时间谢谢大家支持。此贴终止。




欢迎光临 开拓者期货期权程序化系统交易论坛 (http://bbs.tb18.net/) Powered by Discuz! X2