DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)=3
或是新增常用的函數 取個名稱 _settlement
if d<>d[1] then _Settlement=false;
if month(d) <> month(d)[1] then value1=0;
if (dayofmonth(d)>=15 and dayofmonth(d)<=21 and dayofweek(d)=3)
then begin
_Settlement=true;
value1=1;
end
else if value1=0 and
(
(dayofmonth(d)>=16 and dayofmonth(d)<=22 and dayofweek(d)=4) or
(dayofmonth(d)>=17 and dayofmonth(d)<=23 and dayofweek(d)=5) or
(dayofmonth(d)>=18 and dayofmonth(d)<=24 and dayofweek(d)=6) or
(dayofmonth(d)>=20 and dayofmonth(d)<=26 and dayofweek(d)=1) or
(dayofmonth(d)>=21 and dayofmonth(d)<=27 and dayofweek(d)=2) or
(dayofmonth(d)>=22 )
)
then begin
_Settlement=true;
value1=1;
end;
結算日當天 平倉所有的部位
if _settlement then begin
sell next bar at market;
buytocover next bar at market;
end;