“后臺下單模板”,可用于各種模型。不會寫后臺模型的塔友,以后不用寫了,復制此模板即OK
只要把此模板放在 模型的最后面,就可以后臺全自動化交易了。此方法還有一個好處,即使用固定輪詢模式,也不會漏單
注意:把800988替換成自己的賬戶,按ctrl+H 進行替換
有個性化需求的,也可在此模板上的基礎上定制。不會的可以找我
runmode:0;
Globalvariable:hold=drawnull;
……//這里添加上你自己的模型
……//這里添加上你自己的模型
cc800988:=holding;//這句放在信號穩定的地方,即時下單的,就放下單語句的后面,K線走完下單的就放下單語句的前面
drawtextex(1,1,800,0,'虛擬持倉為:'+numtostr(cc800988,0));//在圖表上輸出虛擬持倉以便監控
if not(islastbar) or workmode<>1 then exit;
xiadan800988:=cc800988-hold;
if xiadan800988>0.5 then begin
cang:=min(xiadan800988,abs(hold));
if hold<0 then tsellshort(1,cang,mkt,0,0,'800988'),allowrepeat;
cang:=xiadan800988+min(hold,0);
if cang>0 then tbuy(1,cang,mkt,0,0,'800988'),allowrepeat;
end
if xiadan800988<-0.5 then begin
cang:=min(abs(xiadan800988),abs(hold));
if hold>0 then tsell(1,cang,mkt,0,0,'800988'),allowrepeat;
cang:=abs(xiadan800988)-max(hold,0);
if cang>0 then tbuyshort(1,cang,mkt,0,0,'800988'),allowrepeat;
end
hold:=cc800988;