小幫手午安
我的自動交易參考XQ內建的刪單
但是一直跑出委託操作逾時
主要是希望進場觸發後 三根K棒內沒成交就刪單
程式碼如下
if Position = 0 and long_condition then begin
SetPosition(1); { 以市價買進 }
end else if TrueAll(Position <> Filled, 3) then begin
SetPosition(filled, market); { 取消買進的委託 }
end;
if Position = 1 and Filled = 1 then begin
{ 依照成本價格設定停損/停利 }
if profit_point > 0 and Close >= FilledAvgPrice + profit_point then begin
{ 停利 }
SetPosition(0);
end else if loss_point > 0 and Close <= FilledAvgPrice - loss_point then begin
{ 停損 }
SetPosition(0);
end;
end;
1 評論