2013年10月18日 星期五

Multicharts摩台結算日期

 

摩台結算日是每個月倒數第二個交易日,除了如前篇J所分享的 尾盤出場策略1-建立日期表 所述作一個參考表之外,可以利用一些語法來達成。

 

以下就邊照著程式碼作注釋了。

 

var: M(0),DM(0),DW(0),STWSD(0);

if date <> date[1] then STWSD=0;

M=Month(Date); //取得月份
DM=DayOfMonth(Date); //取得幾日
DW=DayOfWeek(Date); //取得星期幾

 

//如果是大月份的話,結算日期對應星期幾來求出摩台結算日

If M=1 or M=3 or M=5 or M=7 or M=8 or M=10 or M=12 then begin

If DM=30 and DW=4 then STWSD =1;
If DM=30 and DW=3 then STWSD =1;
If DM=30 and DW=2 then STWSD =1;
If DM=30 and DW=1 then STWSD =1;
if DM=29 and DW=4 then STWSD =1;
if DM=28 and DW=5 then STWSD =1;
if DM=28 and DW=4 then STWSD =1;


end;

 

//如果是小月份的話,結算日期對應星期幾來求出摩台結算日

If M=4 or M=6 or M=9 or M=11 then begin

If DM=29 and DW=4 then STWSD =1;
If DM=29 and DW=3 then STWSD =1;
If DM=29 and DW=2 then STWSD =1;
If DM=29 and DW=1 then STWSD =1;
if DM=28 and DW=4 then STWSD =1;
if DM=27 and DW=5 then STWSD =1;
if DM=27 and DW=4 then STWSD =1;


end;

 

//如果是2月份的話,結算日期對應星期幾來求出摩台結算日

If M=2 then begin

If DM=27 and DW=4 then STWSD =1;
If DM=27 and DW=3 then STWSD =1;
If DM=27 and DW=2 then STWSD =1;
If DM=27 and DW=1 then STWSD =1;
if DM=26 and DW=4 then STWSD =1;
if DM=25 and DW=5 then STWSD =1;
if DM=25 and DW=4 then STWSD =1;


end;

 

//台股有時過年過節使得結算日期更改,就把這些日期作記號,往後若有變動也是從這裡加進

if date = 1060124 then STWSD = 1;
if date = 1080926 then STWSD = 1;
if date = 1090120 then STWSD = 1;
if date = 1090526 then STWSD = 1;
if date = 1120224 then STWSD = 1;

 

//以這個語法作指標,可以畫個線圖來觀察

plot1(STWSD,"STWSD");

 

如同下圖,就完成囉。

STWSD

 

 

 

沒有留言:

張貼留言