小幫手 你好
能幫我看一下哪個部位出問題嗎?
他會停利停損
但不能執行移動停損
如 成本100 上漲到110 往下跌5% 應該出在104.5
但商品價位低於104.5也沒賣出呢
input: profit_point(10, "停利(%)");
input: loss_point(5, "停損(%)");
if loss_point = 0 then raiseruntimeerror("請設定停損(點)");
if Position = 1 and Filled = 1 then begin
{ 依照成本價格設定停損/停利 }
var: intrabarpersist stoploss_point(0);
{ 計算停損價格 }
if stoploss_point = 0 then begin
stoploss_point = FilledAvgPrice * (1 - (0.01 * loss_point));
end;
{ 如果價格上漲的話, 則往上挪動停損價格. 停損價格只會越來越高 }
if Close * (1 - (0.01 * loss_point)) > stoploss_point then begin
stoploss_point = Close * (1 - (0.01 * loss_point));
end;
if profit_point > 0 and Close >= FilledAvgPrice * (1 + (0.01 * profit_point)) and close <> getField("漲停價", "D") then begin
{ 停利 }
setposition(0, getfield("跌停價", "D"));
stoploss_point = 0;
end else if Close <= stoploss_point then begin
{ 停損 }
setposition(0, getfield("跌停價", "D"));
stoploss_point = 0;
end;
end;
範例
4/6號買進 美時269.75
4/7號最高價280
4/10號跌破266(280-5%) 要賣出才對
7 評論