隔日出場寫法

  •   329 
  • 最後發表   joE0403  2025 一月 19
joE0403 發文於   2025/01/17

求助:我想要 1. 趴數停損或是 2.特定時間出場,或是3.漲停的話隔天直接出場
{目前寫法,3.有問題,漲停的話會在當天13:29出場}

if Filled > 0 and position > 0 and  close <> GetField("漲停價", "D") 

     then begin 

     if SL>0 AND Close <= FilledAvgPrice*(1-(0.01*SL))   then 

         SetPosition(0); //價格停損

if  CurrentTime >= 130300 then

SetPosition(0); //時間出場

     end ;

 

     

if Filled > 0 and position > 0 and close = GetField("漲停價", "D")

     then begin

if  FilledRecordDate(FilledRecordCount) <> Date  then setposition(0);//價格漲停就換日出場

 

end;

排序方式: 標準 | 最新
虎科大許教授 發文於   2025/01/17

if Filled > 0 and position > 0 and close[1] = GetField("漲停價", "D")[1] then setposition(0);

joE0403 發文於   2025/01/19

謝謝教授,不過這樣寫會出現,如果昨天價格也是漲停,進場當日就有觸發出場的情況

虎科大許教授 發文於   2025/01/19

上述程式會在昨天收盤漲停,今天只要有多頭部位就賣出。若不希望今天再次進場又馬上賣出,可用變數控制。

var: intrabarpersist hasOrdered(false);

if isFirstCall("Date") then hasOrdered=false;

if Filled > 0 and position > 0 and hasOrdered = false and close[1] = GetField("漲停價", "D")[1] then

      begin

            setposition(0);

            hasOrdered=true;

      end;

發表回覆
Close