- 精华
- 0
- 在线时间
- 30 小时
- UID
- 115532
- 积分
- 74
- 帖子
- 28
- 阅读权限
- 30
- 注册时间
- 2013-2-15
- 最后登录
- 2013-4-28
- 精华
- 0
- UID
- 115532
- 积分
- 74
- 帖子
- 28
- 主题
- 7
- 阅读权限
- 30
- 注册时间
- 2013-2-15
- 最后登录
- 2013-4-28
|
zhen2710 发表于 2012-7-6 13:40
好的交易系统很多,有长期的有短期的,关键有一点,就是要坚持,就是短线也要检验期长期的效果,前往不要在 ...
Params
Numeric notbef(9.01);
Numeric notaft(14.55);
Numeric f1(0.32);
Numeric f2(0.06);
Numeric f3(0.14);
Numeric reverse(0.7);
Numeric rangemin(0.1);
Numeric xdiv(3);
Numeric lots(1);
Numeric PercentOfRange(0.5);
Vars
NumericSeries ssetup(0);
NumericSeries bsetup(0);
NumericSeries senter(0);
NumericSeries benter(0);
NumericSeries bbreak(0);
NumericSeries sbreak(0);
NumericSeries ltoday(0);
NumericSeries hitoday(9999);
NumericSeries startnow(0);
NumericSeries div(0);
BoolSeries rfilter(false);
Numeric i_reverse;
Numeric i_rangemin;
Numeric i_vB;
Numeric i_vS;
Numeric DayOpen;
Numeric UpperBand;
Numeric LowerBand;
Numeric PreDayRange;
BoolSeries UpperStoped;
BoolSeries LowerStoped;
Begin
if(date>20131210)return;
If(BarStatus==2 && Time==0.090000 && High==Low) return;
DayOpen = OpenD(0);
UpperBand = DayOpen+PreDayRange*PercentOfRange;
LowerBand = DayOpen-PreDayRange*PercentOfRange;
i_reverse = reverse*(OpenD(0)/100);
i_rangemin = rangemin*(OpenD(0)/100);
if(BarStatus==0)
{
startnow=0;
div=max(xdiv,1);
}
if(Date != Date[1])
{ UpperStoped=True;
LowerStoped=True;
SetGlobalVar(0,0);
SetGlobalVar(1,0);
startnow=startnow+1;
ssetup=hitoday[1]+f1*(Close[1]-ltoday[1]);
senter=((1+f2)/2)*(hitoday[1]+Close[1])-(f2)*ltoday[1];
benter=((1+f2)/2)*(ltoday[1]+Close[1])-(f2)*hitoday[1];
bsetup=ltoday[1]-f1*(hitoday[1]-Close[1]);
bbreak=ssetup+f3*(ssetup-bsetup);
sbreak=bsetup-f3*(ssetup-bsetup);
hitoday=High;
ltoday=Low;
rfilter=(hitoday[1]-ltoday[1])>=i_rangemin;
}
if(High>hitoday)
{
hitoday=High;
}
if(Low<ltoday)
{
ltoday=Low;
}
if(Time*100>=notbef and Time*100<notaft and startnow>=2 and rfilter)
{
if(Time != GetGlobalVar(1) and GetGlobalVar(1) != 0)
{
SetGlobalVar(1,10000);
}
if(hitoday>=ssetup and marketposition>-1 and GetGlobalVar(1)<1 )
{
If(Low<=(senter+(hitoday-ssetup)/div)and Time<0.1400 and high!=low && Low<=LowerBand )
{
SellShort(lots,senter+(hitoday-ssetup)/div);
SetGlobalVar(1,Time);
Return;
}
}
if(ltoday<=bsetup and marketposition<1 and GetGlobalVar(1)<1 )
{
If(High>=(benter-(bsetup-ltoday)/div)and Time<0.1400 and high!=low && High>=UpperBand )
{
Buy(lots,benter-(bsetup-ltoday)/div);
SetGlobalVar(1,Time);
Return;
}
}
if(marketposition==-1)
{
SetGlobalVar(0,1);
if(High-EntryPrice>=i_reverse)
{
BuyToCover(lots,EntryPrice+i_reverse);
Return;
}
}
if(marketposition==1)
{
SetGlobalVar(0,1);
if(EntryPrice-Low>=i_reverse)
{
Sell(lots,EntryPrice-i_reverse);
Return;
}
}
if(marketposition==0)
{
if(High>=bbreak and GetGlobalVar(0) == 0 and Time<0.1400 and high!=low && High>=UpperBand )
{
Buy(lots,bbreak);
Return;
}
}
if(marketposition==0)
{
if(low<=sbreak and GetGlobalVar(0) == 0 and Time<0.1400 and high!=low && Low<=LowerBand )
{
SellShort(lots,sbreak);
Return;
}
}
}
if(Time*100>=notaft and Time<0.1600)
{
if(marketposition==-1)
{
BuyToCover(lots,Open);
}
if(marketposition==1)
{
Sell(lots,Open);
}
}
End |
|