- 精华
- 0
- 在线时间
- 31 小时
- UID
- 233612
- 积分
- 22
- 帖子
- 10
- 阅读权限
- 10
- 注册时间
- 2016-5-3
- 最后登录
- 2021-3-4
- 精华
- 0
- UID
- 233612
- 积分
- 22
- 帖子
- 10
- 主题
- 8
- 阅读权限
- 10
- 注册时间
- 2016-5-3
- 最后登录
- 2021-3-4
|
发表于 2016-12-2 13:20:16
|显示全部楼层
//------------------------------------------------------------------------
// 简称: ITF_T_DualThrust_V101
// 名称: 国贸期货上海营业部量化交易 客户群:186100158
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
Numeric Lots(1);
Numeric TimesMaxToday(1); //限制当天开仓最多次数;
Numeric K1(0.5);
Numeric K2(0.5);
Numeric Mday(1);
Numeric Nday(1);
Numeric offset(0);
Vars
Numeric BuyRange(0);
Numeric SellRange(0);
Numeric BuyTrig(0);
Numeric SellTrig(0);
Numeric HH;
Numeric LL;
Numeric HC;
Numeric LC;
Numeric i_offset;
Numeric BuyPosition;
Numeric SellPosition;
NumericSeries TimesToday(0); //记录当天开仓次数;
Begin
If(Barstatus==2 )
{
If( Time==0.090000 And CurrentTime<=0.090001) Return;
If( Time==0.101500 And CurrentTime<=0.103001) Return;
If( Time==0.133000 And CurrentTime<=0.133001) Return;
}
If(CurrentBar > 44*Max(Mday,Nday))//使用的是5分钟周期,其它的周期自己做相应修改
{
i_offset = offset*MinMove*PriceScale;
HH = Highest(HighD(1),Mday);
HC = Highest(CloseD(1),Mday);
LL = Lowest(LowD(1),Mday);
LC = Lowest(CloseD(1),Mday);
If((HH - LC) >= (HC - LL))
{
SellRange = HH - LC;
}
Else
{
SellRange = HC - LL;
}
HH = Highest(HighD(1),Nday);
HC = Highest(CloseD(1),Nday);
LL = Lowest(LowD(1),Nday);
LC = Lowest(CloseD(1),Nday);
If((HH - LC) >= (HC - LL))
{
BuyRange = HH - LC;
}
Else
{
BuyRange = HC - LL;
}
BuyTrig = K1*BuyRange;
SellTrig = K2*SellRange;
BuyPosition = OpenD(0)+BuyTrig;
SellPosition = OpenD(0)-SellTrig;
PlotNumeric("BuyPosition",BuyPosition);
PlotNumeric("SellPosition",SellPosition);
//开盘第一根K线将当天开仓次数清零;
If(BarsSinceToday==0)
{
TimesToday = 0;
}
//开仓;
If(TimesToday<TimesMaxToday And CurrentBar>90)
{
If(MarketPosition!=1)
{
If(High>=BuyPosition)
{
Buy(lots,Max(Open,BuyPosition)+i_offset);
TimesToday = TimesToday+1;
Return;
}
}
If(MarketPosition!=-1)
{
If(Low<=SellPosition)
{
SellShort(lots,Min(Open,SellPosition)-i_offset);
TimesToday = TimesToday+1;
Return;
}
}
}
//平仓;
If(MarketPosition==1 and Low<=SellPosition)
{
Sell(lots,Min(Open,SellPosition)-i_offset);
TimesToday = TimesToday+1;
Return;
}
If(MarketPosition==-1 and High>=BuyPosition)
{
BuyToCover(lots,Max(Open,BuyPosition)+i_offset);
TimesToday = TimesToday+1;
Return;
}
}
Commentary("当天开仓次数="+Text(TimesToday));
End
//------------------------------------------------------------------------
// 编译版本 GS2010.12.08
// 用户版本 2013/03/28 11:02
// 版权所有 国贸期货上海营业部量化交易 客户群:186100158
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TrabeBlazer公式修改和重写的权利
|
|