
等级: 标准版
- 注册:
- 2022-6-27
- 曾用名:
|

楼主 |
发表于 2023-7-26 10:18
|
显示全部楼层
tcd:(time>=010000 and time<185700);
variable:num:=0; // 全局变量
cs:=3; //限定一天最多亏损3次
ma1:=ma(c,20);
kd:close>ma1; //开多条件
pd:=close<ma1; //平多条件
kk:=close<ma1; //开空条件
pk:=close>ma1; //平空条件
RSV:=(CLOSE-LLV(LOW,6))/(HHV(HIGH,6)-LLV(LOW,6))*100;
K:SMA(RSV,3,1);//快线
D:SMA(K,3,1);//慢线
KD1:=(D-K)>8; //开多条件
PD1:=(K-D)>2; //平多条件
KK1:=(K-D)>1; //开空条件
PK1:=(D-K)>4; //平空条件
ss:=1;//手数
//多
if pd and holding>0 then
begin
sell(1,ss,limitr,close);
if numprofit(1)<0 then num:=num+1; //平多仓
end
if kd and tcd and holding=0 and num<cs then //开多仓
begin
buy(1,ss,limitr,close);
end
//空
if pk and holding<0 then
begin
sellshort(1,ss,limitr,close);
if numprofit(1)<0 then num:=num+1; //平空仓
end
if kk and tcd and holding=0 and num<cs then //开空仓
begin
buyshort(1,ss,limitr,close);
end
if time=closetime(0) then num:=0;
//市价(market)挂单价(limitr)对手价(thisclose)
平空:SELLSHORT(PK1 and cs>3,ss,LIMITR,CLOSE); //平空信号
开多:BUY(KD1 AND tcd and HOLDING=0,SS,LIMITR,CLOSE); //开多信号
平多:SELL(PD1 and cs>3,ss,LIMITR,CLOSE); //平多信号
开空:BUYSHORT(KK1 AND tcd and HOLDING=0,SS,LIMITR,CLOSE); //开空信号
亏损次数:num;
//指定时间平仓
if time=185700 then begin
收盘a:sell(1,ss,limitr,close)coloryellow;//平多
收盘:sellshort(1,ss,limitr,close)colorgreen;//平空
end
hd:holding;
老师,我想是在MA单均线策略亏损3次后,策略执行KD指标策略,是不是在平仓里面改成CS>3,发现这样就不行了,有没有办法解决? |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?
x
|