qsb588986 发表于 2019-7-28 00:02:54

刚出炉。应该劲爆!

Params
Numeric offset(6)        ;
Vars

Numeric totalequity;
Numeric turtleunits;


Begin


TotalEquity = A_FreeMargin + A_TotalMargin;   //账户最新资产 = 按当前Bar开盘价计算的可用资金 + 持仓保证金
TurtleUnits=(TotalEquity/(MarginRatio*ContractUnit()*BigPointValue()*Close)*1/5);
TurtleUnits = IntPart(TurtleUnits); // 对小数取整
if(GetGlobalVar(13)!=8 && BarStatus==2 && time==0.0900 || GetGlobalVar(13)!=8 && BarStatus==2 && time==0.2100)
{
SetGlobalVar(0,1);
SetGlobalVar(4,1);
SetGlobalVar(1,1);
SetGlobalVar(2,1);
SetGlobalVar(20,0);
SetGlobalVar(23,0);
SetGlobalVar(26,0);
SetGlobalVar(27,0);
SetGlobalVar(30,0);
SetGlobalVar(31,0);
SetGlobalVar(13,1);
}
if(GetGlobalVar(14)!=8 && BarStatus==2)
{
SetGlobalVar(0,1);
SetGlobalVar(4,1);
SetGlobalVar(1,1);
SetGlobalVar(2,1);
SetGlobalVar(20,0);
SetGlobalVar(23,0);
SetGlobalVar(26,0);
SetGlobalVar(27,0);
SetGlobalVar(30,0);
SetGlobalVar(31,0);
SetGlobalVar(14,1);
}

if(Q_AskVol>1000 && vol>0)
{
SetGlobalVar(20,Close);
SetGlobalVar(26,Close);
SetGlobalVar(27,Close);
}
if(Close>GetGlobalVar(20) && Close>GetGlobalVar(26))
{
SetGlobalVar(30,1);
SetGlobalVar(26,GetGlobalVar(26)+1);
}
Else
SetGlobalVar(30,2);
if(Close<GetGlobalVar(20) && Close<GetGlobalVar(27))
{
SetGlobalVar(31,1);
SetGlobalVar(27,GetGlobalVar(27)-1);
}
Else
SetGlobalVar(31,2);
if(currenttime>0.090 && currenttime<0.1458 or currenttime>0.2100 && currenttime<0.2258)
{

if(A_BuyPosition==0 && A_SellPosition==0 && BarStatus==2 && vol>0)

{
if(GetGlobalVar(0)==1  && GetGlobalVar(30)==1)
{
A_SendOrder(Enum_Buy,Enum_Entry,TurtleUnits,Q_AskPrice+offset*MinMove*PriceScale);
SetGlobalVar(0,2);
SetGlobalVar(4,2);
SetGlobalVar(2,1);

}
Else if(GetGlobalVar(4)==1 && GetGlobalVar(31)==1)
{

A_SendOrder(Enum_Sell,Enum_Entry,TurtleUnits,Q_BidPrice-offset*MinMove*PriceScale);
SetGlobalVar(4,2);
SetGlobalVar(0,2);
SetGlobalVar(1,1);

}
}

if(A_SellPosition>0 && BarStatus==2  && vol>0)
{

if(GetGlobalVar(1)==1 && GetGlobalVar(30)==1)
{
if(a_todaysellposition>0)
A_SendOrder(Enum_Buy,Enum_ExitToday,A_TodaySellPosition,Q_AskPrice+offset*MinMove*PriceScale);
Else
A_SendOrder(Enum_Buy,Enum_Exit,A_SellPosition,Q_AskPrice+offset*MinMove*PriceScale);
A_SendOrder(Enum_Buy,Enum_Entry,TurtleUnits,Q_AskPrice+offset*MinMove*PriceScale);
SetGlobalVar(1,2);
SetGlobalVar(2,1);

}
}


if(A_BuyPosition>0 && BarStatus==2 && vol>0)
{

if(GetGlobalVar(2)==1 && GetGlobalVar(31)==1)
{
if(A_TodayBuyPosition>0)
A_SendOrder(Enum_Sell,Enum_ExitToday,A_TodayBuyPosition,Q_BidPrice-offset*MinMove*PriceScale);
Else
A_SendOrder(Enum_Sell,Enum_Exit,A_BuyPosition,Q_BidPrice-offset*MinMove*PriceScale);
A_SendOrder(Enum_Sell,Enum_Entry,TurtleUnits,Q_BidPrice-offset*MinMove*PriceScale);
SetGlobalVar(1,1);
SetGlobalVar(2,2);
}
}


}
if(A_GetOpenOrderCount==0)
SetGlobalVar(23,0);
Else
SetGlobalVar(23,1);
if(currenttime>0.1458 && currenttime<0.1500 && A_BuyPosition>0 or currenttime>0.1458 && currenttime<0.1500 && A_SellPosition>0 or currenttime>0.2258 && currenttime<0.2300 && A_BuyPosition>0 or currenttime>0.2258 && time<0.2300 && A_SellPosition>0)
{
if(A_TodayBuyPosition>0)
{
A_SendOrder(Enum_Sell,Enum_ExitToday,A_TodayBuyPosition,Q_BidPrice-offset*MinMove*PriceScale);
SetGlobalVar(23,1);
}
Else
{
A_SendOrder(Enum_Sell,Enum_Exit,A_BuyPosition,Q_BidPrice-offset*MinMove*PriceScale);
SetGlobalVar(23,1);
}
if(a_todaysellposition>0)
{
A_SendOrder(Enum_Buy,Enum_ExitToday,A_TodaySellPosition,Q_AskPrice+offset*MinMove*PriceScale);
SetGlobalVar(23,1);
}
Else
{
A_SendOrder(Enum_Buy,Enum_Exit,A_SellPosition,Q_AskPrice+offset*MinMove*PriceScale);
SetGlobalVar(23,1);
}
}
Commentary("GetGlobalVar(0)"+text(GetGlobalVar(0)));
Commentary("GetGlobalVar(4)"+text(GetGlobalVar(4)));
Commentary("GetGlobalVar(1)"+text(GetGlobalVar(1)));
Commentary("GetGlobalVar(2)"+text(GetGlobalVar(2)));
Commentary("GetGlobalVar(13)"+text(GetGlobalVar(13)));
Commentary("GetGlobalVar(14)"+text(GetGlobalVar(14)));
Commentary("GetGlobalVar(20)"+text(GetGlobalVar(20)));
Commentary("GetGlobalVar(23)"+text(GetGlobalVar(23)));
Commentary("GetGlobalVar(26)"+text(GetGlobalVar(26)));
Commentary("GetGlobalVar(27)"+text(GetGlobalVar(27)));
Commentary("GetGlobalVar(30)"+text(GetGlobalVar(30)));
Commentary("GetGlobalVar(31)"+text(GetGlobalVar(31)));
Commentary("A_BuyPosition"+text(A_BuyPosition));
Commentary("A_SellPosition"+text(A_SellPosition));


End

sj193286 发表于 2019-7-29 16:15:56

可以讲下这个策略的思路吗?谢谢

qsb588986 发表于 2019-7-29 18:51:02

本帖最后由 qsb588986 于 2019-7-29 20:50 编辑

利用委卖盘或者委买盘大于1000手记录当前价。如果最新价大于这个当前价做多。反之做空。

ayumi_wky 发表于 2020-12-28 17:04:42

可惜不能回测啊,这个怎么知晓策略好坏
页: [1]
查看完整版本: 刚出炉。应该劲爆!