如果阳线开多,跌破开仓时阳线的开盘价则止损反手做空;
如果阴线开空,涨过开仓时阴线的收盘价则止损反手做多;
谢谢!
在写,稍后回复
variable:aa=0,bb=0,kd=0,kk=0;
long:=c>o and time>090100 and time<145000;
short:=o>c and time>090100 and time<145000;
//开多
if long and aa=0 then
begin
buy(holding=0,1,thisclose);
aa:=1;
kd:=open;
end
//平多反手
if aa=1 and c<kd then
begin
sell(holding>0,1,market);
aa:=0;
buyshort(holding=0,1,thisclose);
end
//开空
if short and bb=0 then
begin
buyshort(holding=0,1,thisclose);
bb:=1;
kk:=close;
end
//平空反手
if bb and c>kk then
begin
sellshort(holding<0,0,market);
bb:=0;
buy(holding=0,1,thisclose);
end
//多仓止损
if holding>0 and enterbars>1 and c<enterprice-20*mindiff then
止损:sell(1,0,market);
//多仓止盈
if holding>0 and enterbars>1 and c>enterprice+10*mindiff then
止盈:sell(1,0,market);
//空仓止损
if holding<0 and enterbars>1 and c>enterprice+20*mindiff then
空损:sellshort(1,0,market);
//空仓止盈
if holding<0 and enterbars>1 and c<enterprice-10*mindiff then
空盈:sellshort(1,0,market);
if time>=145500 then
begin
sell(holding>0,0,market);
sellshort(holding<0,0,market);
end
if time>=150000 then
begin
aa:=0;
bb:=0;
kd:=0;
kk:=0;
end
由于不知道楼主的平仓反手后的平仓条件,所以自行添加了 平仓条件。
本模块有很多不错的策略,推荐楼主可以多看看.
比方新近的这个帖子写的就很不错.推荐给您http://www.weistock.com/bbs/dispbbs.asp?boardid=11&Id=8840
以下是我的日内交易策略,就缺止损条件了
//中间变量
ZDX:=EMA((EMA(CLOSE,3)+EMA(CLOSE,5)+EMA(CLOSE,8)+EMA(CLOSE,13))/4,2);
JIE:=MA(CLOSE,25);
BRT:=(2*CLOSE+HIGH+LOW)/4;
BRT2:=LLV(LOW,34);
BRT3:=HHV(HIGH,34);
BRTK:=EMA((BRT-BRT2)/(BRT3-BRT2)*100,13);
BRTD:=EMA(0.667*REF(BRTK,1)+0.333*BRTK,2);
MACD:="MACD"(26,12,9);
m5:"ma.ma1";
m10:"ma.ma2";
m20:"ma.ma3";
m30:"ma.ma4";
m60:"ma.ma5";
macddy:=MACD>REF(MACD,1);
macdxy:=MACD<REF(MACD,1);
zf:=C/REF(C,1);
df:=C/REF(C,1);
//开多条件
BU:=(OPEN<ZDX OR REF(CLOSE,1)<ZDX) AND (OPEN<JIE OR REF(CLOSE,1)<JIE) AND CLOSE>JIE AND CLOSE>ZDX AND ZDX>REF(ZDX,1);
BB:=O<M5 AND O<M10 AND O<M20 AND C>M5 AND C>M10 AND C>M20 AND zf>1.00125 AND (M20<(O+C)/2 OR C>M60 or zf>1.003);
LONG:=BU AND macddy AND BB and time>090100 and time<145500;
if long then
begin
sellshort(holding<0,0,limitr,c);
buy(holding=0,limitr,c);
end;
//开空条件
SS:=O>M5 AND O>M10 AND O>M20 AND C<M5 AND C<M10 AND C<M20 AND df<0.99875 AND (M20>(O+C)/2 OR C<M60 or df<0.997);
SE:=OPEN>ZDX AND OPEN>JIE AND C<ZDX AND C<JIE AND macdxy;
SHORT:=SE AND SS and brtd>35 and time>090100 and time<144500;
if short then
begin
sell(holding>0,0,limitr,c);
buyshort(holding=0,limitr,c);
end;
//当日平仓
if TIME>145800 then
begin
sell(holding>0,0,market);
sellshort(holding<0,0,market);
end