ma5:ma(c,10);
ma10:ma(c,30);
cond1:=ref(ma5,1)<ref(ma10,1) and ma5>ma10;
cond2:=ref(ma10,1)<ref(ma5,1) and ma10>ma5;
if cond1 then begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,thisclose);
end
if cond2 then begin
sell(holding>0,0,thisclose);
buyshort(holding=0,0,thisclose);
end
以上述模型为基准,运行在30分钟K线上,效果是收盘价入场;
但是我想实现,以做多为案例,如果盘中最高价突破前面3根K线的最高点,而且这个价格也触发了上面的COND1,那么我就不等到收盘,直接盘中价格入场;如果盘中最高价未触及前3根最高价,则等待30分钟收盘价出现,根据信号选择是否交易;
麻烦帮我实现,同时能够实现历史回测时也有效;
你这个可以盘中下单吗?你前面的程序就是逐K线模式(用不了轮询模式),所以只能产生收盘价以后才能执行程序,
是我搞混了概念,我写了一个不知道满不满足你的要求,看看给点意见,
ma5:ma(c,5);
ma10:ma(c,10);
cond1:=ref(ma5,1)<ref(ma10,1) and ma5>ma10;
cond2:=ref(ma10,1)<ref(ma5,1) and ma10>ma5;
A1:=H>HHV(H,3);
A2:=l<llV(l,3);
IF A1 THEN
BEGIN
SELLSHORT(HOLDING<0,0,MARKET);
BUY(HOLDING=0,1,MARKET);
END
ELSE
BEGIN
if cond1 then
begin
sellshort(holding<0,0,thisclose);
buy(holding=0,1,thisclose);
end
END
IF A2 THEN
BEGIN
SELL(HOLDING>0,0,MARKET);
BUYSHORT(HOLDING=0,1,MARKET);
END
ELSE
BEGIN
if cond2 then
begin
sell(holding>0,0,thisclose);
buyshort(holding=0,0,thisclose);
end
END