现有指标开多条件kd
开空条件kk
当前没有持仓量时出现kk则建仓1手,当前持仓量大于0时出现kk则加仓1手,以此类推,
平仓条件为
A1:=最近一次卖开价位-卖开仓以来最低价;
A2:=持仓均价-A1;
A3:=持仓均价-最近一次卖开价;
当持仓量大于等于2时,收盘价>(如果A1>0则返回A2,否则返回A3的1/2)平全仓;
当持仓量<2时,收盘价>卖开价位位置最高价,平全仓;
当收盘价<W-(W-卖开仓以来最低价)/T,平全仓(w,t 为自设参数);
当离收盘闭市剩余5分钟,平全仓;
以下做多为例
B1:=买开仓以来最高价-最近一次买开价位;
B2:=持仓均价+B1;
B3:=最近一次买开价-持仓价;
当持仓量大于等于2时,收盘价<(如果B1>0,则返回B2,否则返回B3的1/2)全平仓;
当持仓量<2时,收盘价<买开仓价位位置最低价,全平仓;
当收盘价<W+(买开仓以来最高价-W)/T,平全仓(w,t 为自设参数);
if kk then buyshort(1,1,market);
a1:=enterprice-llv(l,enterbars+1);
a2:=avgenterprice-a1;
a3:=avgenterprice-enterprice;
nn:=if(a1>0,a2,0.5*a3)
if and enterbars>0 holding<=-2 and close>nn then sellshort(1,0,market);
if holding>=-2 and holding<0 and close>ref(h,enterbars) then sellshort(1,0,market);
if close<(w-(w-llv(l,enterbars+1))/t) then sellshort(1,0,market);
if kd then buy(1,1,market);
b1:=hhv(h,enterbars+1)-enterprice;
b2:=avgenterprice+b1;
b3:=enterprice-avgenterprice;
mm:=if(b1>0,b2,b3*0.5);
if holding>=2 and close<mm then sell(1,0,market);
if holding<2 and holding>0 and close<ref(l,enterbars) then sell(1,0,market);
if close<(w+(hhv(h,enterbars+1)-w)/t) then sell(1,0,market);
if time0>=timetot0(closetime(0))-5*60 then begin
sell(1,0,market);
sellshort(1,0,market);
end
这是我指标最后两句,以下两个条件是多空开仓条件,加仓和平仓条件我在1楼已经说了
kd:=(CROSS(w,b2) or CROSS(W,B3) OR CROSS(W,B4) OR CROSS(W,B5) OR CROSS(W,B6) OR CROSS(W,B7) OR CROSS(W,B8) OR CROSS(W,B9) OR CROSS(W,B10) OR CROSS(W,B11)) AND C>W AND W>=REF(W,1) and not(date>ref(date,1)) ;
kk:=(CROSS(B2,W) or CROSS(B3,W) OR CROSS(B4,W) OR CROSS(B5,W) OR CROSS(B6,W) OR CROSS(B7,W) OR CROSS(B8,W) OR CROSS(B9,W) OR CROSS(B10,W) OR CROSS(B11,W)) AND C<W AND W<=REF(W,1) and not(date>ref(date,1));
if kk then buyshort(1,1,market);
a1:=enterprice-llv(l,enterbars+1);
a2:=avgenterprice-a1;
a3:=avgenterprice-enterprice;
nn:=if(a1>0,a2,0.5*a3)
if and enterbars>0 holding<=-2 and close>nn then sellshort(1,0,market);
if holding>=-2 and holding<0 and close>ref(h,enterbars) then sellshort(1,0,market);
if close<(w-(w-llv(l,enterbars+1))/t) then sellshort(1,0,market);
if kd then buy(1,1,market);
b1:=hhv(h,enterbars+1)-enterprice;
b2:=avgenterprice+b1;
b3:=enterprice-avgenterprice;
mm:=if(b1>0,b2,b3*0.5);
if holding>=2 and close<mm then sell(1,0,market);
if holding<2 and holding>0 and close<ref(l,enterbars) then sell(1,0,market);
if close<(w+(hhv(h,enterbars+1)-w)/t) then sell(1,0,market);
if time0>=timetot0(closetime(0))-5*60 then begin
sell(1,0,market);
sellshort(1,0,market);
end