MultiCharts程式篇:國外期貨非換日時間的程式處理(包含夏令及冬令時間判斷)
1-以英鎊BP為例
使用交易所時間
資料時間預設為交易所時間就沒有換日問題,細節可以參考另一篇文章 "MultiCharts基礎篇:國外期貨資料時間的儲存、顯示和輸出的比較"。
使用本機時間
, summerTimeS(0000), summerTimeE(0500)
, winterTimeS(0000), winterTimeE(0600);
if time - time[1] >= 100 and time = 0600 + theMins then
begin
isSummer = true;
end
else if time - time[1] >= 100 and time = 0700 + theMins then
begin
isSummer = false;
end;
If isSummer and time >= summerTimeS and time <= summerTimeE then
Begin
theLastDate = julianToDate(dateToJulian(date) - 1);
End
else If not isSummer and time >= winterTimeS and time <= winterTimeE then
Begin
theLastDate = julianToDate(dateToJulian(date) - 1);
End
else
Begin
theLastDate = date;
End;
condition1 = date <> theLastDate;
if condition1 then
begin
print("date = " , date, " time = ", time, " isSummer = ", isSummer, " theLastDate= " , theLastDate, " is last day ");
end
else
begin
print("date = " , date, " time = ", time, " isSummer = ", isSummer, " theLastDate= " , theLastDate, " is not last day ");
end;
輸出值:
date = 1130504.00 time = 450.00 isSummer = TRUE theLastDate= 1130503.00 is last day
date = 1130504.00 time = 455.00 isSummer = TRUE theLastDate= 1130503.00 is last day
date = 1130504.00 time = 500.00 isSummer = TRUE theLastDate= 1130503.00 is last day
date = 1130506.00 time = 605.00 isSummer = TRUE theLastDate= 1130506.00 is not last day
date = 1130506.00 time = 610.00 isSummer = TRUE theLastDate= 1130506.00 is not last day
date = 1130506.00 time = 615.00 isSummer = TRUE theLastDate= 1130506.00 is not last day
說明:
2.非換日判斷:簡單的說就是將跨日後到收盤的日期用一個變數設定成前一天。
此版本為MultiChart 7.4.20.400。
0 意見:
張貼留言