求改为后台程序 参考
INPUT:N(60,5,1000,1),M(65,5,300,1);
手数:=max(3*100000/(c*MULTIPLIER),1);
ma1:=ma(c,n);
上轨:=ma1+m*mindiff;
下轨:=ma1-m*mindiff;
开多条件:=c>上轨;
开空条件:=c<下轨;
if holding>0 and c<ma1 then begin
sell(1,0,limitr,c);
end
//开多
if 开多条件 and holding = 0 then
begin
buy(1,手数,limitr,c);
end
if holding<0 and c>ma1 then begin
sellshort(1,0,limitr,c);
end
//开空
if 开空条件 and holding = 0 then
begin
buyshort(1,手数,limitr,c);
end
//资金:ASSET-1000000,linethick4,colorred,NOAXIS;
STICKLINE(HOLDING=0 ,c,o,10,0),COLORGRAY;
STICKLINE(HOLDING=0 ,h,l,1,0),COLORGRAY;
STICKLINE(HOLDING>0 ,c,o,10,0),COLORRED;
STICKLINE(HOLDING>0,h,l,1,0),COLORRED;
STICKLINE(HOLDING<0,c,o,10,0),COLORGREEN;
STICKLINE(HOLDING<0,h,l,1,0),COLORGREEN;
后台和图表机制有差异,其中一点就是后台是不存在虚拟持仓的,直接针对实际账号上的持仓进行操作的。这一点你需要注意下。思路方面可能要做下调整才行。另外绘图之类的函数在后台显然没发用的。
INPUT:N(60,5,1000,1),M(65,5,300,1);
手数:=max(3*100000/(c*MULTIPLIER),1);
ma1:=ma(c,n);
上轨:=ma1+m*mindiff;
下轨:=ma1-m*mindiff;
开多条件:=c>上轨;
开空条件:=c<下轨;
if TBUYHOLDINGEX('','',1)>0 and c<ma1 then begin
tsell(1,0,lmt,c);
end
//开多
if 开多条件 and tholding = 0 then //tholding在多头和空头持仓量一样时候也会返回0,这点需要明确下。如果你要按照实际多头持仓为0来作为条件的话,就使用TBUYHOLDINGEX
begin
tbuy(1,手数,lmt,c);
end
if TSELLHOLDINGEX('','',1)>0 and c>ma1 then begin
tsellshort(1,0,lmt,c);
end
//开空
if 开空条件 and tholding = 0 then //如果你要按照实际空头持仓为0来作为条件的话,就使用TSELLHOLDINGEX
begin
tbuyshort(1,手数,lmt,c);
end