1.請問如何能夠做到 0930 00 以前下單之委託單,如未能成交委託單,即設定取消?
執行紀錄可見,110年11月8日
3588通嘉,於9時2分0秒 刪除1筆委託單後
3588通嘉,又於9時2分1秒 下單2筆委託單
維持委託2筆 下單 135元,待到9時42分17秒始成交
針對這種情形,想設定9時30分鐘前如未成交即取消委託單。
2. 復自執行紀錄可知 ,執行自動下單並未停損,
原先設定跌1.2%以上,則停損出場。 當盤中10時37分43秒 跌到131.5的價位(-1.87%)
並未出觸發停損機制而下單出場,也不清楚竟未啟動停損
本次執行監控畫面及自動交易程式碼如下,請XQ 協助:

input:percent(100); setinputname(1,"量增比例%");
input:Length(200); setinputname(2,"均量期數");
input:XLimit(True); setinputname(3,"限制最低觸發門檻");
input:atVolume(500); setinputname(4,"最低觸發張數");
input:TXT("建議使用分鐘線"); setinputname(5,"使用說明");
value5 = xfMin_EMA("15", Close,12); //計算15分鐘線12期收盤價的XQ EMA
value6 = xfMin_EMA("5", Close,5);
variable: AvgVolume(0);
settotalbar(Length + 3);
AvgVolume=Average(volume,Length);
if XLimit and volume>200 then
begin
condition1 =Volume > atVolume and volume > AvgVolume *(1+ percent/100) and close>GetField("收盤價", "D")[1] and close>value5 and value5>value5[1];
condition2 =Volume > Volume[1] and volume > AvgVolume *(1+ percent/100)and close>GetField("收盤價", "D")[1] and close>value5 and value5>value5[1];
end;
var: long_condition(false);{ 進場買進作多 }
long_condition = Condition1 or Condition2;
if Position = 0 and long_condition and time>090130 and time<090800 then begin
SetPosition(1, AddSpread(Close, -3),label:="下2檔低買入");Print("低買一");
end else
if Position = 1 and long_condition and time>090130 and time<090800 then begin
SetPosition(2, AddSpread(Close, -4),label:="下3檔低買入");Print("低買二");
/////以買進價為基礎
input: profit_percent(2.5, "停利(%)");
input: loss_percent(1.2, "停損(%)");
input: losss_percent(1, "停損(%)");
if Position =1 and Filled =1 then begin
if losss_percent > 0 and Close <= GetField("收盤價","D")[1]*(1-0.01*losss_percent) then begin
SetPosition(0, market);
{ 依照成本價格設定停損/停利 }
end else if profit_percent > 0 and Close >= FilledAvgPrice*(1+0.01*profit_percent) then begin
{ 停利 }
SetPosition(0, market);
end else if loss_percent > 0 and Close <= FilledAvgPrice*(1-0.01*loss_percent) then begin
{ 停損 }
SetPosition(0, market);
end;
end;
end;
5 評論