if time >= _exit_time and position <> 0 then
begin
SetPosition(0);
RaiseRunTimeError("超過時間全部出清");
end;
if filled > 0 then
begin
_stop_loss = FilledAvgPrice * (1 - _long_sl_percent / 100);
print("8多單停損價格:",_stop_loss);
_take_profit = FilledAvgPrice * (1 + _long_tp_percent / 100);
print("9多單停利價格:",_take_profit);
if close <= _stop_loss then
begin
SetPosition(0);
print("10current close=",close);
print("11停損值:",_stop_loss);
RaiseRunTimeError("多單停損結束執行");
end;
if close >= _take_profit then
begin
SetPosition(0);
print("12current close=",close);
print("13停損值:",_take_profit);
RaiseRunTimeError("多單停利結束執行");
end;
end;
if filled < 0 then
begin
_stop_loss = FilledAvgPrice * (1 + _short_sl_percent / 100);
print("14空單停損價格:",_stop_loss);
_take_profit = FilledAvgPrice * (1 - _short_tp_percent / 100);
print("15空單停利價格:",_take_profit);
if close >= _stop_loss then
begin
SetPosition(0);
print("16current close=",close);
print("17停損值:",_stop_loss);
RaiseRunTimeError("空單停損結束執行");
end;
if close <= _take_profit then
begin
SetPosition(0);
print("18current close=",close);
print("19停損值:",_take_profit);
RaiseRunTimeError("空單停利結束執行");
end;
end;
結果
只有停止執行,而部位都沒有出清,請看附檔
請問為何?
3 評論