請教3模型組合為1單手模型?
作者:金字塔 來源:cxh99.com 發(fā)布時間:2015年07月10日
- 咨詢內(nèi)容:
現(xiàn)有模型A,B,C。分別運行于3、5、8分鐘周期。
如何引用它們的holding持倉量以達到以下目的:
1、當ABC皆為1即做多,則新模型做多buy。
2、當ABC皆為-1即做空,則新模型做空buy short
3、其余時候都全平,持倉為0
請問該如何寫?運行于哪個周期?
[此貼子已經(jīng)被作者于2014/9/3 0:37:44編輯過]
- 金字塔客服:
分別設置3個公式,買入賣出改為holdings=1或者=0或者=-1
在策略里引用三個holdings的值,三者相加=3則做多,=-3做空
新策略要運行在1分鐘周期,才能保證以更小時間間隔執(zhí)行三個策略而不漏單
- 用戶回復:
r1:=todaybar-1;//********************************rr1:=stkindiex('if00','tears25.持倉',0,22,80,0);rr2:=stkindiex('if00','tears25.持倉',0,22,90,0);rr3:=stkindiex('if00','qq25.持倉',0,22,125,0),noaxis;
r12:rr1+rr2+rr3,linethick0;
//*************第一遍*************if r12=3 and p3<=xdd then
begin
buy(holding<cx,tn,limitr,jgx+hd1+hdd);
endif r12=-3 and p3<=xdk then beginbuyshort(abs(holding)<cx,tn,limitr,jgs-hd1-hdk);end//*************第二遍*************if r12=3 and p3<=xdd then
begin
buy(holding<cx,tn,limitr,jgx+hd1+hdd);
endif r12=-3 and p3<=xdk then beginbuyshort(abs(holding)<cx,tn,limitr,jgs-hd1-hdk);end//*************第三遍*************if r12=3 and p3<=xdd then
begin
buy(holding<cx,tn,limitr,jgx+hd1+hdd);
endif r12=-3 and p3<=xdk then beginbuyshort(abs(holding)<cx,tn,limitr,jgs-hd1-hdk);end//********************************
if abs(r12)<=2 and p3<=xdk thenbeginsell(holding>0,0,limitr,jgs-hd1-hdk);endif abs(r12)<=2 and p3<=xdd thenbeginsellshort(holding<0,0,limitr,jgx+hd1+hdk);end
//********************************交易總數(shù):totaltrade,colorwhite,linethick0;盈虧:asset-1000000,colorred,linethick1,noaxis;日盈虧:asset-ref(asset,todaybar),noaxis,colorred,linethick0;虛擬持倉:holding,colorwhite,linethick0;
variable:hc=0;回撤:hhv(盈虧,30000)-盈虧,linethick0,coloryellow;if 回撤>hc then hc:=回撤;最大回撤:hc,linethick0,coloryellow;
[此貼子已經(jīng)被作者于2014/9/3 8:10:35編輯過]
- 網(wǎng)友回復:
如果是用后臺交易,開倉只要寫一遍,就可以了。如果是標準版圖表交易,可以用小一點的周期,看看再同一根k線有幾個同時下單的可能就用幾遍。一般使用輪詢,什么周期都可以。原程序信號不能閃,如果有閃的問題,可以適當延長掃描時間。
- 網(wǎng)友回復:
重新整理一下,前面說的不對,前面說的是凈單交易:
r1:=todaybar-1;//********************************rr1:=stkindiex('if00','tears25.持倉',0,22,80,0);rr2:=stkindiex('if00','tears25.持倉',0,22,90,0);rr3:=stkindiex('if00','tears25.持倉',0,22,125,0),noaxis;
r12:rr1+rr2+rr3,linethick0;
//*****************************if r12=3 then beginbuy(holding=0,tn,limitr,c);endif r12=-3 then beginuyshort(abs(holding)=0,tn,limitr,c);end
//********************************
if abs(r12)<=2 thenbeginsell(holding=0,0,limitr,c);endif abs(r12)<=2 thenbeginsellshort(holding=0,0,limitr,c);end//********************************交易總數(shù):totaltrade,colorwhite,linethick0;盈虧:asset-1000000,colorred,linethick1,noaxis;日盈虧:asset-ref(asset,todaybar),noaxis,colorred,linethick0;虛擬持倉:holding,colorwhite,linethick0;
variable:hc=0;回撤:hhv(盈虧,30000)-盈虧,linethick0,coloryellow;if 回撤>hc then hc:=回撤;最大回撤:hc,linethick0,coloryellow;
什么周期都可以,不要太大(8分,10分都可以)。要使用輪詢,原程序的信號不能閃,否則會來回交易,可以適當延長掃描時間來緩解“信號閃”的問題。也可以在任意周期上使用k線走完模式交易,注意這樣做圖表結果和實盤是有差異的。如果圖表k線周期大于你原程序周期則一致。