想請小幫手幫我看一下出場的語法 :
我下列腳本是寫個股賺2%時自動出場,但我盤中一直看,已經賺了2%以上仍不會自動執行,不知哪裡有誤?感謝
問題1:
//報酬率_ plratio
variable:plratio(0);
//FilledAvgPrice是「商品目前的未平倉成本」
if FilledAvgPrice <> 0 then
plratio = absValue( 100 * (Close - FilledAvgPrice) / FilledAvgPrice )//正負幾%
else
plratio = 0;
//++多單停利(股票):股票(報酬率)
input:_win(1,"股票幾%停利");
if position > 0 and SymbolType = 2 //(2為股票、3為期貨)
and Close - FilledAvgPrice > 0
and plratio > _win
then begin
SetPosition(0, MARKET,label:="多單停利:股票");
Print(Date,Time,"多單停利(股票)+",Close - FilledAvgPrice ,"+",plratio,"%");
end;
//++空單停利(股票):股票(報酬率)
if position < 0 and SymbolType = 2 //(2為股票、3為期貨)
and FilledAvgPrice - Close > 0
and plratio > _win
then begin
SetPosition(0, MARKET,label:="空單停利:股票");
Print(Date,Time,"空單停利(股票):",FilledAvgPrice - close ,"+",plratio,"%");
end;
像今日的華晶科,3/4 11:45時符合1%停利標準,但我看已經11:50分了,理應執行卻沒執行但卻有print出來。


下圖的智原也是,1%到了也沒出場。
我發現有的個股會執行停利出場,但有的不會,好奇怪。

問題2:
假設在自動交易中的介面設定中有設定安控交易,例如同一商品最多擁有部位1張,如一檔股票目前已有多單1張,當再次偵到到可以做多的訊號時,此時安控會控制不讓再下單,但是此時「FilledAvgPrice」會以第1張為主,還是已經變成第2次有做多訊號時但卻被安控阻下單但FilledAvgPrice已被重新給新的值了呢?
問題3:
我昨晚的夜盤也是一樣,有達停利的標準,但是沒有執行停利,可否也請幫我看一下下面的語法是否有誤?
//(夜盤)
input:_point_night(80,"夜盤賺幾點要停利");
if position > 0 and SymbolType = 3 //(2為股票、3為期貨)
and (
(currenttime >= 210001 and currenttime <= 235900)
or
(currenttime >= 000000 and currenttime < 0500000)
)
and Close - FilledAvgPrice > 0
and Close - FilledAvgPrice >= _point_night
then begin
SetPosition(0, MARKET,label:="多單停利:點數停利");
Print(Date,Time,"多單停利:點數停利:夜+ ",Close - FilledAvgPrice,"點");
end;
附上LOG檔與策略
https://drive.google.com/drive/folders/16gCg6hMB7j00mcI2R8R8TStBrlfIm2g?usp=sharing
3 評論