if holding=0 then begin
if h>hh and aa>0 then
buy(1,30%,limit,thisclose),tfilter;
end
if holding=0 then begin
if l<ll and aa<0 then
buyshort(1,30%,limit ,thisclose),tfilter;
end
if holding>0 then begin
if l<ll then
sell(1,holding,limit ,thisclose),tfilter;
end
if holding<0 then begin
if h>hh then
sellshort(1,holding,limit,thisclose),tfilter;
end end
这样写有错吗,但是怎么显示的信号跟我想的不一样,我写的是创N日新高新低的信号,结果不是,测试结果也跟简单图标交易的差很多
hh:=ref(hhv(h,20),1);
ll:=ref(llv(l,20),1);
buycond:=c>hh;
sellcond:=c<ll;
if buycond then begin
sellshort(holding<0,1,thisclose);//创新高时,如果有空单则买入平仓
buy(holding=0,1,thisclose);//创新高时,如果没有持仓则买入开仓
end
if sellcond then begin
sell(holding>0,1,thisclose);//创新低时,如果有多单则卖出平仓
buyshort(holding=0,1,thisclose);//创新低时,如果没有持仓则卖出开仓
end
请参看以上模板编写
1,把变量调试出来看看是否成立
2,如果变量成立却没有信号,请查看一下费率设置的问题
3,把资金量调大