原有模型平仓止损后常出现错误空仓而错过趋势行情,再请老师帮我修改一下交易模型(即把以下原模型中的止损部份去掉,不再设置平仓止损条件,即用反手指令)。
修改思路如下:
当3分钟,5分钟,10分钟3个周期的4均线全部上穿9均线时开多单(可以在不同时间的K线上陆续上穿或陆续下穿)。当3分钟,5分钟,10分钟3个周期的4均线全部下穿9均线时开空单,以此循环。
//公式2(公式2为主体公式):
sh3:=stkindi('','公式1.sh',0,17);
sh5:=stkindi('','公式1.sh',0,2);
sh10:=stkindi('','公式1.sh',0,18);
xc3:=stkindi('','公式1.xc',0,17);
xc5:=stkindi('','公式1.xc',0,2);
xc10:=stkindi('','公式1.xc',0,18);
if sh3 and sh5 and sh10 then buy(holding=0,1,market);
if xc3 or xc5 or xc10 then sell(holding>0,0,market);
sh3_2:=stkindi('','公式1.sh2',0,17);
sh5_2:=stkindi('','公式1.sh2',0,2);
sh10_2:=stkindi('','公式1.sh2',0,18);
xc3_2:=stkindi('','公式1.xc2',0,17);
xc5_2:=stkindi('','公式1.xc2',0,2);
xc10_2:=stkindi('','公式1.xc2',0,18);
if xc3_2 and xc5_2 and xc10_2 then buyshort(holding=0,1,market);
if sh3_2 or sh5_2 or sh10_2 then sellshort(holding<0,0,market);
//公式1:
sh:ma(c,4)>ma(c,9);
xc:cross(ma(c,9),ma(c,4));
//以下为开空平空止损
sh2:cross(ma(c,4),ma(c,9));
xc2:ma(c,4)<ma(c,9);
请老 师麻烦帮我把周期设置为可调参数。谢谢老师!
周期在stkindi函数里面设置,对函数最后一个参数进行修改。如果你不会,也不想学着改,那么我再怎么改写,都不行
其他条件不变,开平仓语句修改一下
if sh3 and sh5 and sh10 then begin
sell(holding>0,0,market);
buyshort(holding=0,1,market);
end
if sh3_2 or sh5_2 or sh10_2 then begin
sellshort(holding>0,0,market);
buy(holding=0,1,market);
end
//公式1:
sh:ma(c,4)>ma(c,9);
xc:cross(ma(c,9),ma(c,4));
sh2:cross(ma(c,4),ma(c,9));
xc2:ma(c,4)<ma(c,9);
另请老师麻烦帮我把周期设置为可调参数。谢谢老师!
老师好!
是下面这样的吗?但出的信号不正常,不知是什么原因?请老师帮我修改后并测试校对一下。谢谢!
/公式2: 公式2是主体公式
sh3:=stkindi('','公式1.sh',0,17);
sh5:=stkindi('','公式1.sh',0,2);
sh10:=stkindi('','公式1.sh',0,18);
xc3:=stkindi('','公式1.xc',0,17);
xc5:=stkindi('','公式1.xc',0,2);
xc10:=stkindi('','公式1.xc',0,18);
if sh3 and sh5 and sh10 then begin sell(holding>0,0,market);
buyshort(holding=0,1,market);
end
sh3_2:=stkindi('','公式1.sh2',0,17);
sh5_2:=stkindi('','公式1.sh2',0,2);
sh10_2:=stkindi('','公式1.sh2',0,18);
xc3_2:=stkindi('','公式1.xc2',0,17);
xc5_2:=stkindi('','公式1.xc2',0,2);
xc10_2:=stkindi('','公式1.xc2',0,18);
if sh3_2 or sh5_2 or sh10_2 then begin sellshort(holding>0,0,market);
buy(holding=0,1,market);
end
老师好!
是下面这样的吗?但出的信号不正常,不知是什么原因?请老师帮我修改后并测试校对一下。谢谢!
另外,交易指令是用的收盘价吗?请帮我改为指令价。
//公式1: sh:ma(c,4)>ma(c,9); xc:cross(ma(c,9),ma(c,4)); sh2:cross(ma(c,4),ma(c,9)); xc2:ma(c,4)<ma(c,9); |
//公式2: 公式2是主体公式
sh3:=stkindi('','公式1.sh',0,17);
sh5:=stkindi('','公式1.sh',0,2);
sh10:=stkindi('','公式1.sh',0,18);
xc3:=stkindi('','公式1.xc',0,17);
xc5:=stkindi('','公式1.xc',0,2);
xc10:=stkindi('','公式1.xc',0,18);
if sh3 and sh5 and sh10 then begin sell(holding>0,0,market);
buyshort(holding=0,1,market);
end
if sh3 and sh5 and sh10 then begin
sell(holding>0,0,limitr,c);
buyshort(holding=0,1,limitr,c);
end
if sh3_2 or sh5_2 or sh10_2 then begin
sellshort(holding>0,0,limitr,c);
buy(holding=0,1,limitr,c);
end