- 精华
- 0
- 在线时间
- 62 小时
- UID
- 253578
- 积分
- 48
- 帖子
- 31
- 阅读权限
- 10
- 注册时间
- 2017-7-7
- 最后登录
- 2018-5-17
- 精华
- 0
- UID
- 253578
- 积分
- 48
- 帖子
- 31
- 主题
- 5
- 阅读权限
- 10
- 注册时间
- 2017-7-7
- 最后登录
- 2018-5-17
|
会编程,苦于无思路。只要你肯分享好的交易思路,我就免费帮你编程,实现共赢。qq523305738
在此分享一个简单的系统,多品种组合效果不错。- //------------------------------------------------------------------------
- // 简称: RRKK_C04
- // 名称:
- // 类别: 公式应用
- // 类型: 用户应用
- // 输出: Void
- //------------------------------------------------------------------------
- //说明:单均线策略
- //源码是交易开拓者(TB)源码,交易周期日线
- //交易品种:c9000、cf000、hc000、i9000、j9000、m9000、rb000、ru000、zc000等商品指数期货
- Params
- Numeric Length1(20); //均价线长度20
- Numeric S1(2); //开仓确认周期数
- Numeric S2(2); //平仓确认周期数
- Numeric Lots(1); //交易手数1手
- Numeric StartPer1(10); //1级跟踪止盈,盈利10%启动
- Numeric StopPer1(100); //1级跟踪止盈,盈利回撤100%触发
- Numeric StartPer2(20); //2级跟踪止盈,盈利20%启动
- Numeric StopPer2(50); //2级跟踪止盈,盈利回撤50%触发
- Numeric StartPer3(30); //3级跟踪止盈,盈利30%启动
- Numeric StopPer3(30); //3级跟踪止盈,盈利回撤30%触发
- Numeric StartPer4(50); //3级跟踪止盈,盈利50%启动
- Numeric StopPer4(15); //3级跟踪止盈,盈利回撤15%触发
- Numeric StopLoss(5); // 止损5%
-
- Vars
- NumericSeries MA1; //均价线
- Bool BuyEntry(False);
- Bool SellEntry(False);
- Bool BuyExit(False);
- Bool SellExit(False);
- NumericSeries HighestAfterEntry; // 开仓后出现的最高价
- NumericSeries LowestAfterEntry; // 开仓后出现的最低价
-
- Begin
- //过滤日线集合竞价
- If(!CallAuctionFilter()) return;
- //MA1
- MA1=AverageFC(Close,Length1);
- PlotNumeric("MA1",MA1);
- //开平仓条件
- BuyEntry=CountIf(Close[1]>MA1[1],S1)==S1;
- SellEntry=CountIf(Close[1]<MA1[1],S1)==S1;
- SellExit=CountIf(Close[1]>MA1[1],S2)==S2;
- BuyExit=CountIf(Close[1]<MA1[1],S2)==S2;
- //程序主体
- If(MarketPosition!=1 && BuyEntry) //满足开多条件
- {
- Buy(Lots,Open);
- Commentary("开多");
- }
- Else If(MarketPosition!=-1 && SellEntry) //满足开空条件
- {
- SellShort(Lots,Open);
- Commentary("开空");
- }
- Else If(MarketPosition==-1 && SellExit) //满足平空条件
- {
- BuyToCover(0,Open);
- Commentary("平空");
- }
- Else If(MarketPosition==1 && BuyExit) //满足平多条件
- {
- Sell(0,Open);
- Commentary("平多");
- }
-
- //1级跟踪止盈,盈利10%启动,盈利回撤100%触发
- If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer1) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer1)
- {
- BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer1));
- }
- If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer1) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer1)
- {
- Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer1));
- }
- //2级跟踪止盈,盈利20%启动,盈利回撤50%触发
- If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer2) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer2)
- {
- BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer2));
- }
- If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer2) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer2)
- {
- Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer2));
- }
-
- //3级跟踪止盈,盈利30%启动,盈利回撤30%触发
- If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer3) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer3)
- {
- BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer3));
- }
- If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer3) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer3)
- {
- Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer3));
- }
-
- //4级跟踪止盈,盈利50%启动,盈利回撤15%触发
- If(MarketPosition==-1 && BarsSinceLastEntry>0 && LowestAfterEntry[1]<=LastEntryPrice*(1-0.01*StartPer4) && High>=LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer4)
- {
- BuyToCover(0,Max(Open,LowestAfterEntry[1]+(LastEntryPrice-LowestAfterEntry[1])*0.01*StopPer4));
- }
- If(MarketPosition==1 && BarsSinceLastEntry>0 && HighestAfterEntry[1]>=LastEntryPrice*(1+0.01*StartPer4) && Low<=HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer4)
- {
- Sell(0,Min(Open,HighestAfterEntry[1]-(HighestAfterEntry[1]-LastEntryPrice)*0.01*StopPer4));
- }
-
- // 启动止损
- If(MarketPosition==-1 && BarsSinceLastEntry>0 && High>=LastEntryPrice*(1+StopLoss*0.01))
- {
- BuyToCover(0,Max(LastEntryPrice*(1+StopLoss*0.01),Open));
- Commentary("空头亏损"+Text(StopLoss)+"%止损");
- }
- If(MarketPosition==1 && BarsSinceLastEntry>0 && Low<=LastEntryPrice*(1-StopLoss*0.01))
- {
- Sell(0,Min(LastEntryPrice*(1-StopLoss*0.01),Open));
- Commentary("多头亏损"+Text(StopLoss)+"%止损");
- }
-
- //记录开仓后高低点
- If(BarsSinceentry == 0)
- {
- HighestAfterEntry = High;
- LowestAfterEntry = Low;
- }else
- {
- HighestAfterEntry = Max(HighestAfterEntry,High); // 记录下当前Bar的最高点,用于下一个Bar的跟踪止损判断
- LowestAfterEntry = Min(LowestAfterEntry,Low); // 记录下当前Bar的最低点,用于下一个Bar的跟踪止损判断
- }
-
-
- End
- //------------------------------------------------------------------------
- // 编译版本: 2017-07-11 091043
- // 内核版本: V2.6.2.14
- // 版权所有 zxjt30920087
- // 更改声明 TradeBlazer Software保留对TradeBlazer平台
- // 每一版本的TradeBlazer公式修改和重写的权利
- //------------------------------------------------------------------------
复制代码 |
-
总评分: 威望 + 3
查看全部评分
|