自動交易多單空單停損停利

  •   503 
  • 最後發表   blue sky  2021 六月 18
blue sky 發文於   2021/06/15

請問小幫手,下述腳本是多單的停損停利,如要改成多單跟空單都可適用的停損停利腳本,該如何修改?

再麻煩小幫手,研究許久,還是不太懂.

 

{多單停損停利(%)}

input: profit_percent(1, "停利(%)");

input: loss_percent(1, "停損(%)");

if Position = 1 and Filled = 1 then begin

{ 依照成本價格設定停損/停利 }

if profit_percent > 0 and Close >= FilledAvgPrice*(1+0.01*profit_percent) then begin

{ 停利 }

SetPosition(0);

end else if loss_percent > 0 and Close <= FilledAvgPrice*(1-0.01*loss_percent) then begin

{ 停損 }

SetPosition(0);

end;

end;

排序方式: 標準 | 最新
XQ小幫手 發文於   2021/06/17

Hello blue sky,

 

空單的position跟filled會是負數,其停利跟停損剛好跟多單的部分相反。

附上交易腳本供您參考。

附加文件

blue sky 發文於   2021/06/18

謝謝小幫手的協助,測試OK

大感謝

發表回覆
Close