chairmin 发表于 2018-3-16 14:11:04

完蛋快。。。。。。。。。

qsb588986 发表于 2018-3-16 17:11:24

自己改下吧!照搬可不成!

LEOKING 发表于 2018-3-19 23:52:05

完全看晕

qsb588986 发表于 2018-3-29 23:25:54

都是些基础,学精就懂了

aacky111 发表于 2018-4-2 14:47:54

这也太复杂了,,建议你选把思路说下,不然这么多代码。。。

qsb588986 发表于 2018-8-25 21:49:26

本帖最后由 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+0.0005 && time==0.0900 or time!=time+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公式修改和重写的权利
//------------------------------------------------------------------------

qsb588986 发表于 2018-8-26 00:18:07

还有一个。最近遇到一段启发。


Params
Numeric offset(6)        ;

Vars

Numeric totalequity;
Numeric turtleunits;
NumericSeries hh;
NumericSeries ll;
NumericSeries count;
Numeric voll;


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(currenttime>0.0850 && currenttime<0.0901 or currenttime>0.2050 && currenttime<0.2101)
{
SetGlobalVar(10,high);
SetGlobalVar(11,low);

}
if(time!=time+0.0003 && time==0.0900 or time!=time+0.0003 && time==0.2100)
count=1;
Else
count=count+1;
if(currenttime>0.0901 && currenttime<0.1457 or currenttime>0.2101 && currenttime<0.2257)
{
if(close>GetGlobalVar(10) && A_BuyPosition>0)
SetGlobalVar(10,high);
if(close>hh && A_BuyPosition>0 && high-low>8)
SetGlobalVar(11,low);


if(close<GetGlobalVar(11) && A_SellPosition>0)
SetGlobalVar(10,high);
if(close<ll && A_SellPosition>0 && high-low>8)
SetGlobalVar(11,low);
}
hh=GetGlobalVar(10);
ll=GetGlobalVar(11);
voll=Average(vol,count);
if(currenttime>0.0909 && currenttime<0.1457 or currenttime>0.2109 && currenttime<0.2257)
{

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

{
if(GetGlobalVar(0)==0 && close>hh+2)
{
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<ll-2)
{

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(GetGlobalVar(1)==0 && close>hh+2)
{
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(GetGlobalVar(2)==0 && close<ll-2)
{
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("GetGlobalVar(10)"+text(GetGlobalVar(10)));
Commentary("GetGlobalVar(11)"+text(GetGlobalVar(11)));
Commentary("hh="+text(hh));
Commentary("ll="+text(ll));
Commentary("voll="+text(voll));
Commentary("count="+text(count));
Commentary("currentbar="+text(CurrentBar));
End


//------------------------------------------------------------------------
// 编译版本:        2018/07/20 192438
// 内核版本:        V2.6.2.13
// 版权所有        qsb588986
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TradeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

caihpng 发表于 2018-9-7 22:52:43

新手看不懂

ad434005 发表于 2018-9-9 16:04:56

神啊,太复杂了。交易真的没有那么复杂。

swjtusan 发表于 2018-10-20 21:14:19

mark
页: 1 [2] 3
查看完整版本: 又一个失败的策略。望大神提谐。