小幫手您好 我改寫移動停利(做空) 的語法時
回測2021/8/4的商品6164 (尾盤拉高應該要停損)
無論時停損條件1發生或停損條件2發生都無法成功停損
不知道我是哪邊寫錯? 請小幫手幫我看看
Q2 我是想寫 如果還達不到停利標準 ,股價反轉,看哪個條件停損條件先發生就觸發平倉 不知道這樣寫對不對
if position=floor(value99) and Filled = floor(value99) then begin
{ 依照成本價格設定停損/停利 }
var: intrabarpersist stoploss_percent(0);
{ 計算停損價格 }
if stoploss_percent = 0 then begin
stoploss_percent = FilledAvgPrice + loss_percent;
end;
{ 如果價格下跌的話, 則往下挪動停損價格. 停損價格只會越來越低 }
if Close < FilledAvgPrice then begin
if Close + loss_percent < stoploss_percent then begin
stoploss_percent = Close + loss_percent;
end;
end;
if profit_percent > 0 and Close <= FilledAvgPrice - profit_percent then begin
{ 停利 }
SetPosition(0);
stoploss_percent = 0;
end else if Close >= stoploss_percent then begin
SetPosition(0);
stoploss_percent = 0;
end else if Close >= FilledAvgPrice*1.015 then begin
{ 停損1 }
SetPosition(0);
stoploss_percent = 0;
alert("停損1 ");
end else if Close >= FilledAvgPrice and C>=AH then begin
{ 停損2 }
SetPosition(0);
stoploss_percent = 0;
alert("停損2 ");
end;
end;
//**無論如何都早上盤收盤前平倉**
if position<>0 and Time>=out_time then SetPosition(0);
1 評論