金字塔策略寫好,但是無法回測,在歷史數(shù)據(jù)回測時候,報告中沒有任何一筆交易 [金字塔]
- 咨詢內(nèi)容: 我的策略是這樣的。
〔逐K線模式〕下一開始有部分代碼,變量、序列變量賦值等等。然后進入后面的運算時候,因為運算過度復雜,所以設定成如下:
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 //盈虧計算
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 //盈虧計算
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)在用〔訓練模式〕回溯到過去的歷史里看,滿足條件的情況下,買賣信號確實發(fā)出了。但是遇到如下問題:1、當某時刻,第一次滿足我的買入條件,于是策略確實提示買入了,但是到了下一根K棒,因為仍然滿足我的買入條件,策略繼續(xù)在提示買入。似乎完全不記得我已經(jīng)在前一根K棒已經(jīng)買入了? 這是不是和我使用了IF NOT(ISLASTBAR) THEN EXIT;有關系呢? 為什么前面的已經(jīng)持倉未被記住呢?2、可能因為1的緣故,在歷史數(shù)據(jù)回測時候,報告中沒有任何一筆交易……因此無法回測了……
請高手稍微指導一下這個菜鳥級的問題。 [此貼子已經(jīng)被作者于2013-2-25 23:29:43編輯過] - 金字塔客服:
圖表的程序化交易的運行邏輯是會不斷刷新K線信號的,當然不會記住你之前的狀態(tài)。
因此你是不能用IF NOT(ISLASTBAR) THEN EXIT;這樣的語法在圖表程序化中使用的
- 用戶回復: 謝謝admin。
(如果不用IF NOT(ISLASTBAR) THEN EXIT,該策略的運算量太大了)那么這種策略要在歷史K線數(shù)據(jù)中回測,有啥其他辦法嗎? - 網(wǎng)友回復: 沒有辦法的,只能是慢慢等他測試了
- 網(wǎng)友回復: 繼續(xù)請教admin,IF NOT(ISLASTBAR) THEN EXIT 這樣的語句,即使在實時行情下運行(即白天行情在進行的時候),也是不允許用在程序化交易中的,包括后臺程序化執(zhí)行,是吧?
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯(lián)系技術人員 QQ: 262069696 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內(nèi)容