我在原本寫好編譯好的固定停損停利的腳本中,嘗試加入移動停利的程式碼,但寫完開始編譯後出現錯誤,但我怎麼看都沒有不對的地方,想請小幫手幫我看看,以下是出現錯誤的部分,他把這一整串當成同一個字了...
if Position <= -1 and Filled <= -1 then begin
{ 依照成本價格設定停損/停利: 請注意當作空時, 判斷是否獲利的方向要改變 }
var: intrabarpersist max_profit_percent(0); { 啟動停利後最大獲利點 }
if loss_percent > 0 and Close >= FilledAvgPrice*(1+0.01*loss_percent) then begin
{ 停損 }
SetPosition(0);
max_profit_percent = 0;
end else begin
{ 判斷是否要啟動停利 }
if max_profit_percent = 0 and Close <= FilledAvgPrice*(1-0.01*profit_percent) then begin
max_profit_percent = Close;
end;
if max_profit_percent <> 0 then begin
if Close >= max_profit_percent*(1+0.01*profit_percent) then begin
{ 停利 }
SetPosition(0);
max_profit_point = 0;
end else if Close < max_profit_point then begin
{ 移動最大獲利點 }
max_profit_point = Close;
end;
if currentTime >= 132000 then SetPosition(0, market);
end;
附上腳本檔
也麻煩小幫手幫我檢視一下我移動停利這樣寫是正確的嗎?謝謝
2 評論