开拓者期货期权程序化系统交易论坛
标题:
会编程,苦于无思路。只要你肯分享好的交易思路,我就免费帮你编程,实现共赢。
[打印本页]
作者:
zxjt30920087
时间:
2017-7-22 08:41:40
标题:
会编程,苦于无思路。只要你肯分享好的交易思路,我就免费帮你编程,实现共赢。
会编程,苦于无思路。只要你肯分享好的交易思路,我就免费帮你编程,实现共赢。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公式修改和重写的权利
//------------------------------------------------------------------------
复制代码
作者:
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