請問小編,我想寫一個偵測庫存只要條件符合自動
移動停利停損或是1-2%停損停利
再麻煩小編
請問小編,我想寫一個偵測庫存只要條件符合自動
移動停利停損或是1-2%停損停利
再麻煩小編
Hello 黑牛,
目前XQ自動交易只有策略部位選擇依庫存,然後在策略啟動時會去讀取當前的策略部位。
啟動後的策略是獨立的,手動操作或其他策略是無法影響其內部紀錄的部位庫存數值。
關於停損停利和移動停利的文章討論區已經有不少了,您可以參考那些文章稍作修改即可。
舉例來說,多方要達成某條件後才停損停利的話大概會是如此:
input: profit_percent(1, "停利(%)");
input: loss_percent(1, "停損(%)");
condition1 = 您的條件...;
if condition1 and position > 0 and filled > 0 then begin
if profit_percent > 0 and Close >= FilledAvgPrice*(1+0.01*profit_percent) then SetPosition(0) //停利
else if loss_percent > 0 and Close <= FilledAvgPrice*(1-0.01*loss_percent) then SetPosition(0); //停損
end;
1 評論