开仓条件:当前价格高与前三根K线的最高价、开多,设置10个点的止损;最新价低于前三根K线的最低价、平仓(不管盈亏),反之开空。
if h>ref(hhv(h,3),1) then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if l<ref(llv(l,3),1) then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
if holding>0 and c<enterprice-10 then sell(1,0,market);
if holding<0 and c>enterprice+10 then sellshort(1,0,market);
老师帮我看看这后台的系统为什么不执行止损呢?思路是这样的:以最新价破前五跟K线的最高价做多,设置4个点止盈、5个点止损,空单反之
此主题相关图片如下:9d7dcxge)$%eaced12vda.png

ZH:='';
PZ1:='RB10';
KD:DYNAINFO2(7, PZ1)>ref(hhv(h,5),1);//开多
KK:DYNAINFO2(7, PZ1)<ref(llv(l,5),1);//开空
if DYNAINFO2(7, PZ1)<=tenterprice-5*MINDIFF then begin//多损
tsell(1,1,MKT,0);
end;
if DYNAINFO2(7, PZ1)>=tenterprice+4*MINDIFF then begin//多盈
tsell(1,1,MKT,DYNAINFO2(7, PZ1),0);
end
if DYNAINFO2(7, PZ1)>=tenterprice+5*MINDIFF then begin//空损
tsellshort(1,1,MKT,DYNAINFO2(7, PZ1),0);
end
if DYNAINFO2(7, PZ1)<=tenterprice-4*MINDIFF then begin //空盈
tsellshort(1,1,MKT,DYNAINFO2(7, PZ1),0);
end
if KK and tbuyholdingex(ZH,pz1,0)=0 and tsellholdingex('',pz1,0)=0 then begin//开空
tbuyshort(1,1,MKT,DYNAINFO2(7, PZ1),0);
end
if KD AND tbuyholdingex('',pz1,0)=0 and tsellholdingex('',pz1,0)=0 then begin //开多
tbuy(1,1,MKT,DYNAINFO2(7, PZ1),0);
end
tsell(1,1,MKT,DYNAINFO2(7, PZ1),0);
这样写要表达什么意思?
把所有的mkt改成lmt 是吧?还是说只改平仓的?
把你想要最新价下单的,都改成lmt
后台下单,mkt后面是不带参数的
lmt后面才带参数
tbuy(1,1,mkt)或者tbuy(1,1,lmt,c,0)
不能是tbuy(1,1,mkt,close,0)
ZH:='';
PZ1:='M09';
KD:DYNAINFO2(7, PZ1)>ref(hhv(h,5),1);//?a?à
KK:DYNAINFO2(7, PZ1)<ref(llv(l,5),1);//?a??
if DYNAINFO2(7, PZ1)<=tenterprice-5*MINDIFF then begin//?à?e
tsell(1,1,LMT,DYNAINFO2(7, PZ1),0);
end;
if DYNAINFO2(7, PZ1)>=tenterprice+4*MINDIFF then begin//?àóˉ
tsell(1,1,LMT,DYNAINFO2(7, PZ1),0);
end
if DYNAINFO2(7, PZ1)>=tenterprice+5*MINDIFF then begin//???e
tsellshort(1,1,LMT,DYNAINFO2(7, PZ1),0);
end
if DYNAINFO2(7, PZ1)<=tenterprice-4*MINDIFF then begin //??óˉ
tsellshort(1,1,LMT,DYNAINFO2(7, PZ1),0);
end
if KK and tbuyholdingex(ZH,pz1,0)=0 and tsellholdingex('',pz1,0)=0 then begin//?a??
tbuyshort(1,1,LMT,DYNAINFO2(7, PZ1),0);
end
if KD AND tbuyholdingex('',pz1,0)=0 and tsellholdingex('',pz1,0)=0 then begin //?a?à
tbuy(1,1,LMT,DYNAINFO2(7, PZ1),0);
end
那我这样改可以吗?