variable:level=0; 定义一个变量level,并赋值为0
oo:=midline; 定义一个变量(参数)midline(中线),并赋值给oo
if holding=0 then begin 如果持仓为0的时候开始执行以下程序
upprice:=oo+grid*mindiff; 定义一个upprice=中线+grid个最小变动价位
if high>=upprice then begin 如果最高价大于upprice,那么执行以下程序
buyshort(1,xdss,limitr,upprice);以限定价格卖开xdss手
level:=1;
end
end
if holding<0 then begin
upprice:=oo+(level+1)*grid*mindiff;
dnprice:=oo+(level-1)*grid*mindiff;
if low<=dnprice then begin
sellshort(1,xdss,limitr,dnprice);
level:=level-1;
end
if high>=upprice then begin
buyshort(1,xdss,limitr,upprice);
level:=level+1;
end
if time=closetime(0) then
sellshort(1,holding,limitr,close);
end
第一个问题:如果“if high>=upprice then begin”、“if low<=dnprice then begin”出现出的比较条件不用最高价和最低价,改为当时的价格(最新价)怎么该?更改后会不会有冲突?我是想实现定义一个中线,每上涨一个网格宽度加空1手,每回落一个网格宽度减仓1手,如果这两个条件的中的最高价、最低价都改成现价,会不是出现程序不知道是开多还是平空的情况?
第二个问题,buyshort(1,xdss,limitr,upprice) 这是开仓语句,我想不用限价开仓,我想用最新价开仓或者市价开仓,分别该怎么修改?
1.把high,low改成close。问题是会产生信号闪烁
2最新价开仓:buyshort(1,xdss,limitr,close);
市价开仓:buyshort(1,xdss,marketr);
改完之后它是一出信号立即下单吗?
if time=closetime(0) then
sellshort(1,holding,limitr,close);
这句话的意思是收盘全部清仓吗?
如果我想最多持仓量为200手该如何限定?就是手中有200手单子后就不再执行开仓命令了该怎么限定?
1.出信号立即下单还是走完k线下单,取决于图表交易的设置,固定轮训是即时下单,走完k线下单是要等到k线走完后,和代码无关,在这里设置:
此主题相关图片如下:1.png

2.收盘时清仓
3. 开仓条件加入 abs(holding)<200