您好
假設我設定的購買條件
a買用b賣
c買用d賣
賣的條件都是設定當庫存有產品及執行
要如何避免a買變成c賣
c買變成b賣呢?
您好
假設我設定的購買條件
a買用b賣
c買用d賣
賣的條件都是設定當庫存有產品及執行
要如何避免a買變成c賣
c買變成b賣呢?
Hello NICK TZ,
您可以多設個變數來記錄是用何種條件入場。
例如:
var: entry_condition(0);
condition1 = A進場條件;
condition2 = B出場條件;
condition3 = C進場條件;
condition4 = D出場條件;
if entry_condition = 0 then begin
if condition1 then begin //以A條件進場,並將 entry_condition 設為1
setposition(1, market);
entry_condition = 1;
end;
if condition3 then begin //以C條件進場,並將 entry_condition 設為2
setposition(1, market);
entry_condition = 2;
end;
end;
if entry_condition = 1 and condition2 then begin //在entry_condition 為1的情況下以B條件出場,並將 entry_condition 設為0
setposition(0, market);
entry_condition = 0;
end;
if entry_condition = 2 and condition4 then begin //在entry_condition 為2的情況下以D條件出場,並將 entry_condition 設為0
setposition(0, market);
entry_condition = 0;
end;
1 評論