停損 再緩緩觀望3分鐘

  •   223 
  • 最後發表   散散惹人愛  2024 十一月 12
散散惹人愛 發文於   2024/11/12

請問 當 停損條件

如 condition18 狀況發生時(盤中一觸發)不立即停損出場,

而是 condition18  成立後 再觀望 3 分鐘 仍然滿足 condition18 時 

或 condition19 ? Close > FilledAvgPrice*(1+0.01*loss_percent)

試編譯如下,各方豪傑要是你會如何撰寫? 感謝指教

 

 

var: intrabarpersist _time(0);

input:losss_percent(0.6, "小停損(%)"),loss_percent(1.6, "大停損(%)"); 

condition18 =

currentTime>110540 and GetField("收盤價","5")>GetField("均價","D")

and  Close > FilledAvgPrice*(1+0.01*losss_percent);


 

if filled<=-1 then begin   

if condition18 and _time = 0 then _time = currenttime;

 

if AbsValue(timediff(currenttime, _time, "M")) >= 3 and condition18

then SetPosition(0,label:="空錯回補");

 

 

虎科大許教授 發文於   2024/11/12

寫法會根據你的確切需求而不同。若前兩分鐘condition18都是true,但第三分鐘為false,第四分鐘又是true,要怎麼處理?還是你的需求是連續三分鐘都是true才停損?

若是連續三分鐘都是true就停損,在1分鐘頻率下,可表達如下:

if TrueAll(condition18,3) or condition19 then setposition(0);

  • 按讚來自於
  • Kesler
發表回覆
Close