- 精华
- 0
- 在线时间
- 525 小时
- UID
- 213396
- 积分
- 187
- 帖子
- 140
- 阅读权限
- 40
- 注册时间
- 2015-7-10
- 最后登录
- 2023-4-14
- 精华
- 0
- UID
- 213396
- 积分
- 187
- 帖子
- 140
- 主题
- 26
- 阅读权限
- 40
- 注册时间
- 2015-7-10
- 最后登录
- 2023-4-14
|
本帖最后由 qsb588986 于 2018-8-26 00:12 编辑
又写了一个。
Params
Numeric offset(6) ;
Vars
Numeric totalequity;
Numeric turtleunits;
NumericSeries hh;
NumericSeries ll;
Numeric hhh;
Numeric lll;
Numeric hhhh;
Numeric llll;
Numeric gg;
Numeric aa;
NumericSeries gd;
NumericSeries count;
Numeric hbar;
Numeric lbar;
Numeric hhbar;
Numeric llbar;
Numeric hhxbar;
Numeric llxbar;
Numeric hhx;
Numeric llx;
Begin
if(isCallAuctionTime())
Return;
TotalEquity = Portfolio_CurrentCapital() + Portfolio_UsedMargin(); //账户最新资产 = 按当前Bar开盘价计算的可用资金 + 持仓保证金
TurtleUnits=(TotalEquity/(MarginRatio*ContractUnit()*BigPointValue()*Close))*6/10;
TurtleUnits = IntPart(TurtleUnits); // 对小数取整
if(0.0800<currenttime && currenttime<0.0900 && high==low or 0.1530<currenttime && currenttime<0.2100 && high==low or GetGlobalVar(0)==InvalidNumeric)
SetGlobalVar(0,0);
if(0.0800<currenttime && currenttime<0.0900 && high==low or 0.1530<currenttime && currenttime<0.2100 && high==low or GetGlobalVar(1)==InvalidNumeric)
SetGlobalVar(1,0);
if(0.0800<currenttime && currenttime<0.0900 && high==low or 0.1530<currenttime && currenttime<0.2100 && high==low or GetGlobalVar(2)==InvalidNumeric)
SetGlobalVar(2,0);
if(0.0800<currenttime && currenttime<0.0900 && high==low or 0.1530<currenttime && currenttime<0.2100 && high==low or GetGlobalVar(4)==InvalidNumeric)
SetGlobalVar(4,0);
if(time!=time[1]+0.0005 && time==0.0900 or time!=time[1]+0.0005 && time==0.2100)
count=1;
Else
count=count+1; \\初始化周期数。
hh=Highest(High,count); \\求当天最高价。
ll=Lowest(low,count); \\求当天最低价。
hbar=HighestBar(High,count); \\求当天最高价之后的BAR数。
lbar=LowestBar(low,count); \\求当天最低价之后的BAR数。
hhh=Highest(High,lbar); \\求当天最低价之后的最高价(次高价)。
lll=Lowest(Low,hbar); \\求当天最高价之后的最低价(次低价)。
hhxbar=HighestBar(high,lbar); \\求当天次高价之后的BAR数。
llxbar=LowestBar(low,hbar); \\求当天次低价之后的BAR数。
hhx=Highest(High,llxbar); \\求当天次低价之后的最高价(次次高价)。
llx=lowest(low,hhxbar); \\求当天次高价之后的最低价(次次低价)
gd=hh-ll;
if(lll==ll && hhh!=hh && llx!=ll && llx<hhh-gd/3)
gg=llx+gd/3;
Else if(lll!=ll && hhh==hh)
gg=lll+(gd/3);
else if(ll==lll)
gg=ll+(gd/3);
if(lll!=ll && hhx!=hh && hhh!=hh && hhx==hhh && hhxbar!=0)
aa=hhx-gd/3;
Else if(hhh!=hh && lll==ll)
aa=hhh-(gd/3);
else if(hh==hhh)
aa=hh-gd/3;
if(currenttime>0.0900 && currenttime<0.1457 or currenttime>0.2100 && currenttime<0.2257)
{
if(A_BuyPosition==0 && A_SellPosition==0 && BarStatus==2 )
{
if(GetGlobalVar(0)==0 && close>gg && gd>6)
{
A_SendOrder(Enum_Buy,Enum_Entry,TurtleUnits,Q_AskPrice+offset*MinMove*PriceScale);
SetGlobalVar(0,1);
SetGlobalVar(4,1);
SetGlobalVar(2,0);
}
Else if(GetGlobalVar(4)==0 && close<aa && gd>6)
{
A_SendOrder(Enum_Sell,Enum_Entry,TurtleUnits,Q_BidPrice-offset*MinMove*PriceScale);
SetGlobalVar(0,1);
SetGlobalVar(4,1);
SetGlobalVar(1,0);
}
}
if(A_SellPosition>0 && BarStatus==2 && vol>0)
{
if(close>gg && GetGlobalVar(1)==0)
{
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,0);
}
if(close-A_SellAvgPrice>30)
{
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);
SetGlobalVar(1,1);
SetGlobalVar(2,1);
SetGlobalVar(4,1);
SetGlobalVar(0,1);
}
}
if(A_BuyPosition>0 && BarStatus==2 && vol>0)
{
if(close<aa && GetGlobalVar(2)==0)
{
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(2,2);
SetGlobalVar(1,0);
}
if(A_BuyAvgPrice-close>30)
{
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);
SetGlobalVar(2,1);
SetGlobalVar(1,1);
SetGlobalVar(0,1);
SetGlobalVar(4,1);
}
}
}
if(currenttime>0.1457 && currenttime<0.1500 && A_BuyPosition>0 or currenttime>0.1457 && currenttime<0.1500 && A_SellPosition>0 or currenttime>0.2257 && currenttime<0.2300 && A_BuyPosition>0 or currenttime>0.2257 && time<0.2300 && A_SellPosition>0)
{
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);
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);
}
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("hh="+text(hh));
Commentary("ll="+text(ll));
Commentary("vol="+text(vol));
Commentary("count"+text(count));
Commentary("gd="+text(gd));
Commentary("gg="+text(gg));
Commentary("aa="+text(aa));
Commentary("hhh="+text(hhh));
Commentary("lll="+text(lll));
Commentary("hbar="+text(hbar));
Commentary("lbar="+text(lbar));
Commentary("llxbar="+text(llxbar));
Commentary("hhx="+text(hhx));
Commentary("llx="+text(llx));
Commentary("hhxbar="+text(hhxbar));
End
//------------------------------------------------------------------------
// 编译版本: 2018/06/28 001530
// 内核版本: V2.6.2.13
// 版权所有 qsb588986
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------ |
|