-- 作者:skylands
-- 发布时间:2013/12/9 12:24:50
-- 请帮忙看看这个限损策略
我这个按信号次数来限损的策略,请帮忙看看整个的语句写法中有没有漏洞。另外,在图表中显示时,信号次数总是比程序中的少几次,不完全正确。
1分钟策略:
限损:任何60分钟内连续出现信号次数超过10次,立即平仓离场,当日不再交易,次日重新开始。
//交易系统
variable:X=0;
cs:=count(KDPK1,60)+count(KDPK2,60)+count(KKPD1,60)+count(KKPD2,60);
//60分钟内4类交易信号的次数之和
if ref(cs>=10,1) then //前一根满足60分钟内信号次数超过10次的条件
begin
sell(holding>0,holding,marketr);
sellshort(holding<0,holding,marketr);
X:=1;
end
if time=closetime(0) then X:=0;
if X=0 then
begin
sellshort((KDPK1 or KDPK2) and
holding<0,holding,marketr);
buy((KDPK1 or KDPK2) and holding=0,30%,thisclose);
sell((KKPD1 or KKPD2) and
holding>0,holding,marketr);
buyshort((KKPD1 or KKPD2) and holding=0,30%,thisclose);
end
|