小幫手好,我想要在空單進場的時候以ATR的波動倍數來停利出場,如題,實際交易卻沒觸發,煩請小幫手幫忙看看程式碼:
input:pst(1,"部位"),
ATR_length(10,"ATR期間"),s_numsATR(3.4,"ATR倍數"),ATR_osc(20,"ATR波動");
var:i(false),time_temp(0);
condition1=//多條件
condition2=//空條件
condition3=atr_stop_profit(ATR_length,s_numsATR,position) and c<filledAvgPrice and ATR(10)>ATR_osc;
if position<>pst then
if condition1 then setposition(pst,market);
if position<>neg(pst) then
if condition2 then setposition(neg(pst),market);
if position<>0 then
if date=getlastTradeDate(dateValue(Date,"M"),dateValue(Date,"Y")) and (time>=132000 and time<=133000)
then setposition(0,market,label:="到期日平倉");
if position>0 then
if condition2 then setposition(0,market);
if position<0 then begin
if condition1 then setposition(0,market)
else if condition3 then setposition(0,market,label:="ATR空平倉");
end;
6 評論