想請教為何以下腳本沒辦法回測

  •   93 
  • 最後發表   蓬蘇王杜  2025 九月 10
蓬蘇王杜 發文於   2025/09/04

想請教為何以下腳本沒辦法回測 , 是因為條件太複雜嗎

 

value1 = 5 ; //漲幅進場%
value2 = 6 ; //獲利目標%
value3 = 6 ; //停損點
value4 = highest(high,20); //20天高
value5 = lowest(low,60); //60天低
value6 = 30 ; //60天漲幅條件
value7 = 20 ; //股價回測不得低於條件
value8 = average(close,5); //5ma
value9 = average(close,10); //10ma
value10 = average(close,20); //20ma
value11 = average(close,60); //60ma



vars: intrabarpersist highx(0); //紀錄高點
//進場
condition1 = value4 >= value5*(1+value6*0.01) ; //60天漲幅>=30%
condition2 = close >= value4*(1-value7*0.01) ; //回檔不得超過20%
condition3 = close >= close[1]*(1+value1*0.01) ; //漲幅進場
condition4 = close <= value8*1.1 ; //不得乖離5ma 大於10%
condition5 = close >= value9 and close >= value10 and close >= value11 ; //大於等於 10 / 20 / 60 ma


if filled=0 and condition1 and condition2 and condition3 and condition4 and condition5 then begin
   setposition(1, label:="in'");
   highx = 0 ;
end;

if filled = 1 and close < filledavgPrice*(1-value3*0.01) then
   setposition(0, label:="母單停損'") ;

if filled = 1 and close > filledavgPrice*1.03 then 
   setposition(3, label:="加碼'") ;

if filled = 3 then begin
   if close > highx then highx = close ;
   if highx >= filledavgPrice*(1+value2*0.01) and close < highx*0.94 then
   setposition(0, label:="停利") ;


end;

 

排序方式: 標準 | 最新
虎科大許教授 發文於   2025/09/04

我用16.04版本回測,回測一年時間,有結果,但交易分析裡面卻顯示沒有任何交易資料。看起來這個應該是XQ的bug。會請產品部門了解狀況。

蓬蘇王杜 發文於   2025/09/04

我也是這樣 , 謝謝教授~

虎科大許教授 發文於   2025/09/08

這是因為setposition(1, label:="in'"); Label中有單引號的關係。

你可以先拿掉單引號看看。XQ產品部門已經在處理這個問題。

蓬蘇王杜 發文於   2025/09/10

原來如此 謝謝教授

發表回覆
Close