等级: 超级版主
- 注册:
- 2021-5-18
- 曾用名:
|
//批量把下面的账号 改为登录的交易账号就行了。
Globalvariable:hold=drawnull;
cc账号:=holding;//这句放在信号稳定的地方
//此部分改为你自己的模型(K线走完模型)
MA1:MA(CLOSE,5);
MA2:MA(CLOSE,3);
SELLSHORT( CROSS(MA1,MA2),1,MARKET);
BUY(HOLDING=0 AND CROSS(MA1,MA2),1,MARKET);
SELL(CROSS(MA1,MA2),1,MARKET);
BUYSHORT(CROSS(MA1,MA2),1,MARKET);
//
drawtextex(1,1,800,0,'虚拟持仓为:'+numtostr(cc账号,0));//在图表上输入虚拟持仓以便监控
if not(islastbar) or workmode<>1 then exit;
xiadan账号:=cc账号-hold;
if xiadan账号>0.5 then begin
cang:=min(xiadan账号,abs(hold));
if hold<0 then begin
tsellshort(1,cang,mkt,0,0,'账号'),allowrepeat;
//debugfile('D:\账号.txt',numtostr(hold,0)+' '+numtostr(cc账号,0)+' 平空 %.0f',cang);
end
cang:=xiadan账号+min(hold,0);
if cang>0 then begin
tbuy(1,cang,mkt,0,0,'账号'),allowrepeat;
//debugfile('D:\账号.txt',numtostr(hold,0)+' '+numtostr(cc账号,0)+' 开多 %.0f',cang);
end
end
if xiadan账号<-0.5 then begin
cang:=min(abs(xiadan账号),abs(hold));
if hold>0 then begin
tsell(1,cang,mkt,0,0,'账号'),allowrepeat;
//debugfile('D:\账号.txt',numtostr(hold,0)+' '+numtostr(cc账号,0)+' 平多 %.0f',cang);
end
cang:=abs(xiadan账号)-max(hold,0);
if cang>0 then begin
tbuyshort(1,cang,mkt,0,0,'账号'),allowrepeat;
//debugfile('D:\账号.txt',numtostr(hold,0)+' '+numtostr(cc账号,0)+' 开空 %.0f',cang);
end
end
hold:=cc账号; |
|