“后臺(tái)下單模板”,可用于各種模型。不會(huì)寫后臺(tái)模型的塔友,以后不用寫了,復(fù)制此模板即OK
只要把此模板放在 模型的最后面,就可以后臺(tái)全自動(dòng)化交易了。此方法還有一個(gè)好處,即使用固定輪詢模式,也不會(huì)漏單
注意:把800988替換成自己的賬戶,按ctrl+H 進(jìn)行替換
有個(gè)性化需求的,也可在此模板上的基礎(chǔ)上定制。不會(huì)的可以找我
runmode:0;
Globalvariable:hold=drawnull;
……//這里添加上你自己的模型
……//這里添加上你自己的模型
cc800988:=holding;//這句放在信號(hào)穩(wěn)定的地方,即時(shí)下單的,就放下單語句的后面,K線走完下單的就放下單語句的前面
drawtextex(1,1,800,0,'虛擬持倉為:'+numtostr(cc800988,0));//在圖表上輸出虛擬持倉以便監(jiān)控
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;