R-Breaker策略[TradeStation源码]
R-Breaker策略[TradeStation源码]:[code]
{R-Breaker}
{***********SystemSetup*******************
Trading between 9:15 and 14:29 ChicagoTime only
MMStop $1000
Close End of Day
10 min Time Frame
******************************************}
input:notbef(715),notaft(1229);
var:{input:}f1(.35),f2(0.07),f3(.25),reverse(2.00),
rangemin(1.15),xdiv(3);
var:ssetup(0),bsetup(0),senter(0),benter(0),bbreak(0),sbreak(0),
ltoday(0),hitoday(9999),startnow(0),div(0),
rfilter(false);
if currentbar=1 then startnow=0;
div=maxlist(xdiv,1);
if d>d[1] then begin
startnow=startnow+1;
ssetup=hitoday[1]+f1*(c[1]-ltoday[1]);
senter=((1+f2)/2)*(hitoday[1]+c[1])-(f2)*ltoday[1];
benter=((1+f2)/2)*(ltoday[1]+c[1])-(f2)*hitoday[1];
bsetup=ltoday[1]-f1*(hitoday[1]-c[1]);
bbreak=ssetup+f3*(ssetup-bsetup){(1.3625*hitoday[1]+.45*c[1])-.8125*ltoday[1]};
sbreak=bsetup-f3*(ssetup-bsetup){(1.3625*ltoday[1]+.45*c[1])-.8125*hitoday[1]};
hitoday=h;
ltoday=l;
rfilter=hitoday[1]-ltoday[1]>=rangemin;
end;
if h>hitoday then hitoday=h;
if l<ltoday then ltoday=l;
if t>=notbef and t<notaft and startnow>=2 and rfilter and
date>entrydate(1) then begin
if hitoday>=ssetup and marketposition>-1 then
SELL("Rlev SE") senter+(hitoday-ssetup)/div stop;
if ltoday<=bsetup and marketposition<1 then
BUY("Rlev LE") benter-(bsetup-ltoday)/div stop;
if marketposition=-1 then
BUY("RbUP LE") entryprice+reverse stop;
if marketposition=1 then
SELL("RbDN SE") entryprice-reverse stop;
if marketposition=0 then
BUY("Break LE") bbreak stop;
if marketposition=0 then
SELL("Break SE") sbreak stop;
end;
if t>=notaft and t<>sess1endtime then begin
if marketposition=-1 then
EXITSHORT("RbUP SX") entryprice+reverse stop;
if marketposition=1 then
EXITLONG("RbDN LX") entryprice-reverse stop;
EXITSHORT("Late SX") h+.05 stop;
EXITLONG("Late LX") l-.05 stop;
END;
[/code] {:48:}
页:
[1]