
等级: 新手上路
- 注册:
- 2023-2-18
- 曾用名:
|

楼主 |
发表于 2023-2-21 15:06
|
显示全部楼层
Variable:longprice=O,shortprice=O;
{……………条件板块}{条件声明语句}
{0号条件}
2hhstp:=ref(hhv(high,120),1);//2小时以内的最高价
2hlstp:=ref(llv(low,120),1);//2小时以内的最低价;
0号条件:high>=2hhstp or low<=2hlstp;
{扩张阈值突破X值的计算}
L1:=(ref(tr,1)+ref(tr,2)+ref(tr,3)+ref(tr,4)+ref(tr,5)),5;
L2:=tr;
X:L2/L1;
{均线形态得分Y值的计算}
MA5:=MA(CLOSE,5);
MA10:=MA(CLOSE,10);
MA20:=MA(CLOSE,20);
MA60:=MA(CLOSE,60);
MAl20:=MA(CLOSE,120);
{Y1的计算}
k1:=if(c>=MA5,if(MA5>MA10,0,1),if(MA5<MA1O,0,1));
k2:=if(c>=ma5,if(ma10>ma20,0,1),if(ma10<ma20,0,1));
k3:=if(c>=ma5,if(ma20>ma60,0,1),if(ma20<ma60,0,1));
k4:=if(c>=ma5,if(ma60>ma120,0,1),if(ma60<mal20,0,1));
k:=k1+k2+k3+k4;//不符合顺序发散关系的均线对数;
Y1:=1-0.2*k;
{Y2的计算}
最高均线:=max(ma5,max(max10,max(ma20,max(ma60,ma120))));
最低均线:=min(ma5,min(ma10,min(ma20,min(ma60,ma120))));
高低均线差:=最高均线-最低均线;
Y2:=if(ma5<>ma10,abs(ma5-ma10)/高低均线差,abs(ma5-ma20)/高低均线差);
{Y的计算} Y:=max(Y1,Y2);
{平台突破效率Z的计算}
ZH:=ref(hhv(high,5),1);
ZL:=ref(llv(low,5),1);
Zz:=if(high<=ZH and low>=ZL,0,if(high>ZH,(high-ZH)/(ZH-ZL),(ZL-low)/(ZH—ZL)));
Z:=zZ;
{量能扩张倍数V的ji算}
v5:=(ref(vol,1)+ref(vol,2)+ref(vol,3)+ref(vol,4)+ref(vol,5))/5;
R:=v/v5;
{典型K线}
实体占比:abs(c-o)/abs(high-low);
典型K线:=实体占比>=0.7;
{…一一…~一一一…一-交易板块}{佼易控制语句}
做多条件:=交易条件 and c>ma5 and oktime and holding=0;
做空条件:=交易条件 and c<ma5 and oktime and holding=0;
{开仓条件}
ohime:=(time>=10500 and time<=60000)or(time>=130500 and time<=183000);
条件1:X>=2.4 and X<=5,noaxis;
条件2:Y>=0.6,noaxis;
条件3:z>=0.8,noaxis;
条件4:R>=2 and R<=6,noaxis;
交易条件:=条件1 and 条件2 and 条件3 and 条件4 and 0号条件 and 典型K线;
{平仓条件}
hstp:=hhv(high,enterbars+2);//持仓最高;
Istp:=llv(low,enterbars+2);//持仓最低;
if holding>O and longprice=O then
begin
longprice:=o;
enter:=1;
end
if holding<O and shortprice=O then
begin
shortprice:=o;
enter:=l;
end
if holding=O then
begin
shortprice:=O;
longprice:=O;
end
{止损}if holding>O and hstp<longprice+4 then sell(low<=longprice-8 and C<O,0,market);
if holding<O and lstp>shortprice-4 then sellshort(high>=shortprice+8 and C>O,0,market);
{止盈}if holding>O and hstp>=longprice+4 then sell(low<=hstp-12 and C<o,0,market);
if holding<O and lstp<=shortprice-4 then sellshort(high>=lstp+12 and C>O,0,market);
{开仓}
buy(做多条件,60%,market);
buyshort(做空条件,60%,market);
{收盘平仓以及全局变量复位}
if(time>=062800 and time<=063000)or(time>=185800 and time<=190000)
if then
begin
sell(holding>O,0,market);
sellshort(holding<0,0,market);
longprice:=O;
shortprice:=0;
end |
|