// 定義參數
input: volumePercentThreshold(5, "主力持股百分比");
input: jumpOpenPercent(3, "開盤跳空高開百分比");
input: priceDropPercent(2, "進場放空的股價下跌百分比");
input: priceRallyPercent(2, "回補出場的股價急拉百分比");
input: forcedCoverTime(132000, "強制平倉時間");
variable: shortEntryPrice(0), shortExitPrice(0), shortEntryDate(0);
variable: initialCapital(1000000), currentCapital(1000000);
variable: isHighVolume(false), isJumpOpen(false), isShortPosition(false), isCoverSignal(false);
variable: prevVolume(0), currentVolume(0);
if date > 1 then begin
variable: prevClose(0);
prevClose = getfield("close", "D")[1];
prevVolume = getfield("volume", "D")[1];
isHighVolume = (prevVolume / getfield("volume", "D")[1]) * 100 >= volumePercentThreshold;
end;
variable: currentTradeDate(CurrentDate), marketTime(CurrentTime);
variable: marketHour(marketTime / 100), marketMinute(marketTime - (marketHour * 100));
variable: currentMarketTime(NumToStr(marketHour, 2) + ":" + NumToStr(marketMinute, 2));
isJumpOpen = ((open / getfield("close", "D")[1]) - 1) * 100 >= jumpOpenPercent;
if marketTime >= 090000 and marketTime <= 100000 and isHighVolume and isJumpOpen then begin
if ((close / open) - 1) * 100 <= (-priceDropPercent) then begin
isShortPosition = true;
shortEntryPrice = close;
shortEntryDate = currentTradeDate;
// 記錄進場動作
print("Short at ", close, " on ", shortEntryDate);
end;
end;
if isShortPosition then begin
isCoverSignal = ((close / shortEntryPrice) - 1) * 100 >= priceRallyPercent;
if isCoverSignal then begin
shortExitPrice = close;
isShortPosition = false;
currentCapital = currentCapital + (shortEntryPrice - shortExitPrice) * 1000;
print("Cover at ", close, " on ", currentTradeDate, ". Profit: ", shortEntryPrice - shortExitPrice);
print("Current Capital: ", currentCapital);
end;
end;
if isShortPosition and marketTime >= forcedCoverTime then begin
shortExitPrice = close;
isShortPosition = false;
currentCapital = currentCapital + (shortEntryPrice - shortExitPrice) * 1000;
print("Force Cover at ", close, " on ", currentTradeDate, ". Profit: ", shortEntryPrice - shortExitPrice);
print("Current Capital: ", currentCapital);
end;
print("Date: ", currentTradeDate, " - Current Capital: ", currentCapital);
請問以上腳本在編譯時是成功的回測卻無數據,請問是哪個地方有問題導致回測不到數據。
 
 
             
        
         
         
         
     
     分類
    分類
 
            
2 評論