各位大神好,
請問以下腳本編譯正常,回測時有觸法進場但一直無法觸發出場,
我需要怎樣修正才能正常觸發出場?
input: largeSellOrderThreshold(10, "拋售單閾值");
input: largeBuyOrderThreshold(10, "買進單數量");
input: jumpOpenPercent(3, "跳空百分比");
input: priceDropPercent(2, "股價下跌");
input: priceRallyPercent(2, "股價急拉");
input: lowPointRallyPercent(2, "低點急拉");
input: forcedCoverTime(100000, "強制平倉時間");
variable: shortEntryPrice(0), shortEntryDate(0), stopLossPrice(0), coverPrice(0);
variable: isShortPosition(false);
variable: lowPoint(0), marketTime(0), currentTradeDate(0), isLargeSellOrder(false), isLargeBuyOrder(false);
marketTime = CurrentTime;
currentTradeDate = CurrentDate;
print("Current Market Time: ", NumToStr(marketTime, 6));
if marketTime >= 90000 and marketTime <= 100000 then begin
if ((open / close[1]) - 1) * 100 >= jumpOpenPercent then begin
if getfield("volume", "tick") >= largeSellOrderThreshold then begin
isLargeSellOrder = true;
end else begin
isLargeSellOrder = false;
end;
if isLargeSellOrder and ((close / open) - 1) * 100 <= (-priceDropPercent) then begin
isShortPosition = true;
shortEntryPrice = close;
shortEntryDate = currentTradeDate;
lowPoint = low;
setposition(-1);
print("Short at ", close, " on ", NumToStr(shortEntryDate, 8));
end;
end;
end;
if isShortPosition then begin
if getfield("volume", "tick") >= largeBuyOrderThreshold then begin
isLargeBuyOrder = true;
end else begin
isLargeBuyOrder = false;
end;
if isLargeBuyOrder or ((close / shortEntryPrice) - 1) * 100 >= priceRallyPercent or ((close / lowPoint) - 1) * 100 >= lowPointRallyPercent or marketTime >= forcedCoverTime then begin
setposition(0);
print("Cover at ", close, " on ", NumToStr(currentTradeDate, 8));
isShortPosition = false;
end;
end;
print("Date: ", NumToStr(currentTradeDate, 8), " - Is Short Position: ", isShortPosition);
2 評論