金字塔策略寫好,但是無法回測(cè),在歷史數(shù)據(jù)回測(cè)時(shí)候,報(bào)告中沒有任何一筆交易 [金字塔]
- 咨詢內(nèi)容: 我的策略是這樣的。
〔逐K線模式〕下一開始有部分代碼,變量、序列變量賦值等等。然后進(jìn)入后面的運(yùn)算時(shí)候,因?yàn)檫\(yùn)算過度復(fù)雜,所以設(shè)定成如下:
IF NOT(ISLASTBAR) THEN EXIT;……后面接余下的代碼。包含這段,買賣模版if holding=0 then begin
6 //多頭開倉
7 if tradingtime and enlongcond then begin
8 buy(1,1,limitr,close);
9 maxprofit:=0;
10 end
11
12 //空頭開倉
13 if tradingtime and enshortcond then begin
14 buyshort(1,1,limitr,close);
15 maxprofit:=0;
16 end
17 end
18
19 if holding>0 then begin
20 //多頭平倉
21 if exlongcond then
22 sell(1,holding,limitr,close);
23
24 //多頭收盤平倉
25 if not(tradingtime) then
26 sell(1,holding,limitr,close);
27
28 //盈虧計(jì)算
29 if enterbars>0 then begin
30 win:=(c-enterprice)/enterprice*100;
31 if win>maxprofit then
32 maxprofit:=win;
33 win2:=(maxproift-win)/maxprofit*100;
34 end
35
36 //多頭初始止損
37 if win<-2 then
38 sell(1,holding,limitr,close);
39
40 //多頭利潤止盈
41 if win>4 then
42 sell(1,holding,limitr,close);
43
44 //多頭回撤止盈
45 if win2>60 and openprofit>0 then
46 sell(1,holding,limitr,close);
47 end
48
49 if holding<0 then begin
50 //空頭平倉
51 if exshortcond then
52 sellshort(1,holding,limitr,close);
53
54 //空頭收盤平倉
55 if not(tradingtime) then
56 sellshort(1,holding,limitr,close);
57
58 //盈虧計(jì)算
59 if enterbars>0 then begin
60 win:=(enterprice-c)/enterprice*100;
61 if win>maxprofit then
62 maxprofit:=win;
63 win2:=(maxprofit-win)/maxprofit*100;
64 end
65
66 //空頭初始止盈
67 if win<-2 then
68 sellshort(1,holding,limitr,close);
69
70 //空頭利潤止盈
71 if win>4 then
72 sellshort(1,holding,limitr,close);
73
74 //空頭回撤止盈
75 if win2>60 and openprofit>0 then
76 sellshort(1,holding,limitr,close);
77 end
78
現(xiàn)在用〔訓(xùn)練模式〕回溯到過去的歷史里看,滿足條件的情況下,買賣信號(hào)確實(shí)發(fā)出了。但是遇到如下問題:1、當(dāng)某時(shí)刻,第一次滿足我的買入條件,于是策略確實(shí)提示買入了,但是到了下一根K棒,因?yàn)槿匀粷M足我的買入條件,策略繼續(xù)在提示買入。似乎完全不記得我已經(jīng)在前一根K棒已經(jīng)買入了? 這是不是和我使用了IF NOT(ISLASTBAR) THEN EXIT;有關(guān)系呢? 為什么前面的已經(jīng)持倉未被記住呢?2、可能因?yàn)?的緣故,在歷史數(shù)據(jù)回測(cè)時(shí)候,報(bào)告中沒有任何一筆交易……因此無法回測(cè)了……
請(qǐng)高手稍微指導(dǎo)一下這個(gè)菜鳥級(jí)的問題。 [此貼子已經(jīng)被作者于2013-2-25 23:29:43編輯過] - 金字塔客服:
圖表的程序化交易的運(yùn)行邏輯是會(huì)不斷刷新K線信號(hào)的,當(dāng)然不會(huì)記住你之前的狀態(tài)。
因此你是不能用IF NOT(ISLASTBAR) THEN EXIT;這樣的語法在圖表程序化中使用的
- 用戶回復(fù): 謝謝admin。
(如果不用IF NOT(ISLASTBAR) THEN EXIT,該策略的運(yùn)算量太大了)那么這種策略要在歷史K線數(shù)據(jù)中回測(cè),有啥其他辦法嗎? - 網(wǎng)友回復(fù): 沒有辦法的,只能是慢慢等他測(cè)試了
- 網(wǎng)友回復(fù): 繼續(xù)請(qǐng)教admin,IF NOT(ISLASTBAR) THEN EXIT 這樣的語句,即使在實(shí)時(shí)行情下運(yùn)行(即白天行情在進(jìn)行的時(shí)候),也是不允許用在程序化交易中的,包括后臺(tái)程序化執(zhí)行,是吧?
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容