當沖交易買賣,希望依訊號進場後,再依停損停利而出場。避免依訊號而進出場(目前情況)
如何避開程式碼中的
1. =====>B買進 被 =======>S賣出 而賣出?
2.=======>S賣出 被 =====>B買進 而買進?
買進// 如果條件成立時
if position=0 and filled=0 and condition91 /如果條件成立時
then begin
if condition92 then setposition(position+1,close,label:="買"); //92條件也成立時買進======>B
if position<>0 and filled<>0 then //假如成交買進
value95=100 * (Close - FilledAvgPrice) / FilledAvgPrice;//停利停損%
if filled=1 and value95 >=X1 then setposition(0,close,label:=">買進續漲%停利"); //獲利停利
if filled=1 and value95 <=-x2 then setposition(0,close,label:="<買進回跌%停損"); //虧損停損
end;
//賣出
if position=1 and filled=1 and condition91 //如果有該股且條件符合
then begin
if condition93 then setposition(position-1,close,label:="賣"); //條件93也成立時賣出=====>S
if position=0 and filled=-1 then
value95=100 * (Close - FilledAvgPrice) / FilledAvgPrice;//停利停損%
if filled=-1 and value95 <=-X3 then setposition(0,close,label:="賣出續跌%停利");
if filled=-1 and value95 >=x4 then setposition(0,close,label:="賣出回漲%停損");
end;
1 評論