------自己改寫的雙軌道交易系統(tǒng) ,為神馬回測(cè)是0呢 [金字塔]
- 咨詢內(nèi)容:
不是數(shù)據(jù)導(dǎo)入的問(wèn)題 ,因?yàn)?其余的系統(tǒng)策略回測(cè)沒(méi)有問(wèn)題
代碼如下 ,測(cè)試編譯沒(méi)有問(wèn)題
之前回測(cè)有數(shù)據(jù)的 ,也不知道出了什么問(wèn)題 一夜之后不行了
//中間變量
INPUT:N(16,1,30,1),K1(0.4,0.1,1,0.1),K2(0.8,0.1,1,0.1),NMIN(6,1,10,1),SS(100,100,1000,100);
//INPUT:P1(3,1,5,1),P2(80,10,100,10);{計(jì)算最大回撤止損};
VARIABLE:P2=80;
variable:MAXPROFIT:=0;
variable:PROFIT:=0;
variable:DOWNPROFIT:=0;
variable: EX=0;
CYC:=BARSLAST(DATE<>REF(DATE,1))+1;
LHIGH:=CALLSTOCK(STKLABEL,VTHIGH,6,-1);
LLOW:=CALLSTOCK(STKLABEL,VTLOW,6,-1);
LCLOSE:=CALLSTOCK(STKLABEL,VTCLOSE,6,-1);
TOPEN:=VALUEWHEN(CYC=1,OPEN);
HH:=HHV(LHIGH,N);//N日HIGH的最高價(jià)
HC:=HHV(LCLOSE,N);//N日CLOSE的最高價(jià)
LC:=LLV(LCLOSE,N);//N日CLOSE的最低價(jià)
LL:=LLV(LLOW,N);//N日LOW的最低價(jià)
MOVING:=MAX(HH-LL,HC-LL);//RANGE
T1:=TIME>=090200 AND TIME<=145000+NMIN*100;
T2:=TIME>=145000+NMIN*100 AND TIME<=150000;
HOLDER:=SS;
幅度:=0;
UP:TOPEN+K1*MOVING;
DOWN:TOPEN-K2*MOVING;
BUYCON:=C>UP AND HOLDING=0 ;
BUYSHORTCON:=C<DOWN AND HOLDING=0 ;
虧跳:=10;
盈跳:=200;
{
多頭浮虧10跳止損條件: (ENTERPRICE-C)>5*MINDIFF();
空頭浮虧10跳止損條件: (C-ENTERPRICE)>5*MINDIFF();
}
//移動(dòng)動(dòng)態(tài)止損部分
///每天的 開(kāi)盤的時(shí)候 持倉(cāng)為0 開(kāi)倉(cāng)為0
IF TIME =090100 THEN BEGIN
EXTGBDATASET('B',0);//A 代表是否有倉(cāng)位 b代表是否開(kāi)過(guò)倉(cāng)位
EXTGBDATASET('A',0);
END
///
//持有空倉(cāng)的情況
IF HOLDING=0 THEN BEGIN
IF T1 THEN BEGIN
IF BUYCON THEN BEGIN
BUY( EXTGBDATA('B')=0 AND EXTGBDATA('A')=0,HOLDER,MARKET);
EXTGBDATASET('A',1);
EXTGBDATASET('B',1);
END
IF BUYSHORTCON THEN BEGIN
BUYSHORT( EXTGBDATA('B')=0 AND EXTGBDATA('A')=0,HOLDER,MARKET);
EXTGBDATASET('A',-1);
EXTGBDATASET('B',1);
END
END
END
IF HOLDING>0 THEN BEGIN
IF T1 THEN BEGIN
//最高價(jià)格 浮虧10跳 止盈操作
//浮虧10跳 止損
IF ( AVGENTERPRICE()-DYNAINFO( 7)>10*MINDIFF) THEN BEGIN
SELL(1,HOLDER,MARKET);
EXTGBDATASET('A',0);
EXTGBDATASET('B',1);
END
//
END
IF T2 THEN BEGIN
SELL(1,HOLDER,MARKET);
EXTGBDATASET('A',0);
EXTGBDATASET('B',0);
END
END
IF HOLDING<0 THEN BEGIN
IF T1 THEN BEGIN
IF ( DYNAINFO( 7)-AVGENTERPRICE()>10*MINDIFF) THEN BEGIN
SELLSHORT(1,HOLDER,MARKET);
EXTGBDATASET('A',0);
EXTGBDATASET('B',1);
END
END
IF T2 THEN BEGIN
SELLSHORT(1,HOLDER,MARKET);
EXTGBDATASET('A',0);
EXTGBDATASET('B',0);
END
END
//交易系統(tǒng)
{
開(kāi)多:BUY(開(kāi)多條件 AND T1 AND CYC>1,手?jǐn)?shù),MARKET);
開(kāi)空:BUYSHORT(開(kāi)空條件 AND T1 AND CYC>1,手?jǐn)?shù),MARKET);
收盤平多:SELL(T2,手?jǐn)?shù),MARKET);
收盤平空:SELLSHORT(T2,手?jǐn)?shù),MARKET);
}
當(dāng)前持倉(cāng):HOLDING,COLORGRAY,LINETHICK0;
當(dāng)前資產(chǎn):ASSET,NOAXIS,COLORGRAY;//輸出當(dāng)前資產(chǎn),但不影響坐標(biāo)最高最低值 - 金字塔客服:
不要重復(fù)發(fā)帖
http://www.weistock.com/bbs/dispbbs.asp?boardid=2&Id=142077
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 511411198 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容