R-BREAK策略Word文件下载.docx
《R-BREAK策略Word文件下载.docx》由会员分享,可在线阅读,更多相关《R-BREAK策略Word文件下载.docx(10页珍藏版)》请在冰点文库上搜索。
//修订时间:
2012.11.1
//DesignedByRogarz
input:
ss(1,1,100,10);
手数:
=ss;
n:
=barslast(date<
>
ref(date,1));
昨高:
=callstock(stklabel,vthigh,6,-1);
//昨高
昨低:
=callstock(stklabel,vtlow,6,-1);
//昨低
昨收:
=callstock(stklabel,vtclose,6,-1);
//昨收
a:
=hhv(h,n+1);
b:
=llv(l,n+1);
ifN>
=1thenbegin
今高:
=a;
//今高
今低:
=b;
//今低
end
观察卖出价:
昨高+0.35*(昨收-昨低);
//ssetup
反转卖出价:
(1.07/2)*(昨高+昨低)-0.07*昨低;
//senter
反转买入价:
(1.07/2)*(昨高+昨低)-0.07*昨高;
//benter
观察买入价:
昨低-0.35*(昨高-昨收);
//bsetup
突破买入价:
(观察卖出价+0.25*(观察卖出价-观察买入价));
//bbreeak
突破卖出价:
观察买入价-0.25*(观察卖出价-观察买入价);
//sbreak
//条件
空仓做多条件:
=c>
突破买入价andholding=0;
空仓做空条件:
=c<
突破卖出价andholding=0;
多单反转条件:
=holding>
0and今高>
观察卖出价andc<
反转卖出价;
空单反转条件:
=holding<
0and今低<
观察买入价andc>
反转买入价;
//交易系统
iftime>
=092000andtime<
151000thenbegin
空仓开多:
buy(空仓做多条件,手数,market);
空仓开空:
buyshort(空仓做空条件,手数,market);
//多单反转:
if多单反转条件thenbegin
平多:
sell(1,手数,market);
翻空:
buyshort(1,手数,market);
//空单反转:
if空单反转条件thenbegin
平空:
sellshort(1,手数,market);
翻多:
buy(1,手数,market);
//日内平仓
=151000thenbegin
收盘平多:
收盘平空:
这个策略之前在论坛中有发不过。
Z7C9版:
Jinzhe版:
这个策略参照国外的经验较适用于股指,在商品上的表现一般,所以此处收盘我以股指为例。
我写这个版本,主要是为了做个可读性强的范例。
代码忠于策略本身的思想,没有设置止盈止损,各位可自行添加。
其他考虑不周,或有错的地方。
还请各位指教。
//参数版
ss(1,1,100,10),n1(0.35,0.1,1,0.05),n2(0.07,0.01,0.1,0.01),n3(0.25,0.01,1,0.05);
昨高+n1*(昨收-昨低);
((1+n2/2))*(昨高+昨低)-n2*昨低;
((1+n2/2))*(昨高+昨低)-n2*昨高;
昨低-n1*(昨高-昨收);
(观察卖出价+n3*(观察卖出价-观察买入价));
观察买入价-n3*(观察卖出价-观察买入价);
1、
runmode:
0;
notbef(090000);
notaft(145500);
f1(0.35);
f2(0.07);
f3(0.25);
myreverse
(1);
rangemin(0.2);
xdiv(3);
variable:
ssetup=0;
bsetup=0;
senter=0;
benter=0;
bbreak=0;
sbreak=0;
ltoday=0;
hitoday=999999;
startnow=0;
div=0;
rfilter=false;
i_reverse:
=myreverse*(callstock(stklabel,vtopen,6,0)/100);
i_rangemin:
=rangemin*(callstock(stklabel,vtopen,6,0)/100);
ifbarpos=1thenbegin
startnow:
=0;
div:
=max(xdiv,1);
hh:
=ref(hitoday,1);
cc:
=ref(close,1);
ll:
=ref(ltoday,1);
ifdate>
ref(date,1)thenbegin
=startnow+1;
ssetup:
=hh+f1*(cc-ll);
senter:
=((1+f2)/2)*(hh+cc)-f2*ll;
benter:
=((1+f2)/2)*(ll+cc)-f2*hh;
bsetup:
=ll-f1*(hh-cc);
bbreak:
=ssetup+f3*(ssetup-bsetup);
sbreak:
=bsetup-f3*(ssetup-bsetup);
hitoday:
=high;
ltoday:
=low;
rfilter:
=hh-cc>
=rangemin;
ifhigh>
hitodaythenhitoday:
iflow<
ltodaythenltoday:
=notbefandtime<
notaftandstartnow>
=2andrfilterthenbegin
ifhitoday>
=ssetupandholding>
=0thenbegin
=senter+(hitoday-ssetup)/divthenbegin
sell(1,holding,limitr,senter+(hitoday-ssetup)/div);
sellshort(1,1,limitr,senter+(hitoday-ssetup)/div);
end
ifltoday<
=bsetupandholding<
=benter-(bsetup-ltoday)/divthenbegin
sellshort(1,holding,limitr,benter-(bsetup-ltoday)/div);
buy(1,1,limitr,benter-(bsetup-ltoday)/div);
ifholding<
0thenbegin
ifhigh-enterprice>
=i_reversethen
sellshort(1,enterprice+i_reverse);
ifholding>
ifenterprice-low>
sell(1,enterprice-i_reverse);
ifholding=0thenbegin
=bbreakthen
buy(1,bbreak);
=sbreakthen
sellshort(1,sbreak);
=notaftthenbegin
0then
sellshort(1,holding,limitr,open);
sell(1,holding,limitr,open);
盈亏:
asset-500000,noaxis,coloryellow,linethick2;
2、
zg:
valuewhen(date<
ref(date,1),ref(hhv(h,n+1),1));
zd:
ref(date,1),ref(llv(l,n+1),1));
zs:
ref(date,1),ref(c,1));
jg:
hhv(h,n+1);
jd:
llv(l,n+1);
=zg+0.35*(zs-zd);
//中轨上顶部区间
=(1.07/2)*(zg+zd)-0.07*zd;
=(1.07/2)*(zg+zd)-0.07*zg;
zgsqj:
=senter+(zg-ssetup)/3;
//中轨上区间
zgxqj:
=benter-(ssetup-zd)/3;
//中轨下区间
=zd-0.35*(zg-zs);
=(ssetup+0.25*(ssetup-bsetup));
//上轨
=bsetup-0.25*(ssetup-bsetup);
//下轨
ifcross(c,bbreak)thenbuy(holding=0,1,thisclose);
ifjg>
zgsqjandjg<
bbreakandcross(zgsqj,c)thenbegin
sell(holding>
0,0,thisclose);
buyshort(holding=0,1,thisclose);
ifcross(c,sbreak)thenbuyshort(holding=0,1,thisclose);
ifjd<
zgxqjandc>
sbreakandcross(c,zgxqj)thenbegin
sellshort(holding<
buy(holding=0,1,thisclose);