ma20:=ma(c,20);
a5:=ma(asset,5);
if cross(close,ma20) then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if cross(ma20,close) then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
if cross(asset,a5) and h>ma20 then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if cross(asset,a5) and l<ma20 then begin
sell(1,0,market);
buyshort(holding=0,1,market);
end
虚拟有初始的资金,没有交易也有数值
上面的4个IF就是你4个想法,顺序都不变的
ma20:=ma(c,20);
a5:=ma(asset,5);
variable:n=0;
if cross(close,ma20) and n=0 then begin
sellshort(1,0,market);
if holding=0 then begin
buy(holding=0,1,market);
n:=1;
end
end
if cross(ma20,close) and n=0 then begin
sell(1,0,market);
if holding=0 then begin
buyshort(holding=0,1,market);
n:=1;
end
end
if cross(asset,a5) and h>ma20 and n=1 then begin
sellshort(1,0,market);
buy(holding=0,1,market);
end
if cross(asset,a5) and l<ma20 and n=1 then begin
sell(1,0,market);
buyshort(holding=0,1,market